mirror of https://github.com/AxioDL/metaforce.git
Very, very incomplete integration of hsh/boo2
This commit is contained in:
parent
5b4441ac36
commit
3827f35227
|
@ -1,9 +1,6 @@
|
|||
[submodule "hecl"]
|
||||
path = hecl
|
||||
url = ../hecl.git
|
||||
[submodule "specter"]
|
||||
path = specter
|
||||
url = ../specter.git
|
||||
[submodule "nod"]
|
||||
path = nod
|
||||
url = ../nod.git
|
||||
|
@ -37,3 +34,9 @@
|
|||
[submodule "Editor/locale"]
|
||||
path = Editor/locale
|
||||
url = ../urde-translations.git
|
||||
[submodule "boo2"]
|
||||
path = boo2
|
||||
url = ../boo2.git
|
||||
[submodule "zeus"]
|
||||
path = zeus
|
||||
url = ../zeus.git
|
||||
|
|
|
@ -6,18 +6,15 @@
|
|||
<mapping directory="$PROJECT_DIR$/NESEmulator/fixNES" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/amuse" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/assetnameparser/tinyxml2" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/boo2" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/boo2/logvisor" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/boo2/logvisor/fmt" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/discord-rpc" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/hecl" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/hecl-gui" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/hecl/extern/athena" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/hecl/extern/athena/extern/fmt" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/hecl/extern/athena/extern/lzokay" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/hecl/extern/boo" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/hecl/extern/boo/glslang" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/hecl/extern/boo/lib/graphicsdev/nx/libdrm_nouveau" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/hecl/extern/boo/lib/graphicsdev/nx/mesa" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/hecl/extern/boo/logvisor" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/hecl/extern/boo/logvisor/fmt" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/hecl/extern/libSquish" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/hecl/extern/libjpeg-turbo" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/jbus" vcs="Git" />
|
||||
|
@ -28,8 +25,6 @@
|
|||
<mapping directory="$PROJECT_DIR$/rapidjson" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/rapidjson/thirdparty/gtest" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/sanitizers-cmake" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/specter" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/specter/freetype2" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/specter/zeus" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/zeus" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
|
@ -279,10 +279,9 @@ set(HECL_DATASPEC_PUSHES
|
|||
hecl::Database::DATA_SPEC_REGISTRY.push_back(&DataSpec::SpecEntMP3PC);
|
||||
hecl::Database::DATA_SPEC_REGISTRY.push_back(&DataSpec::SpecEntMP3ORIG);")
|
||||
|
||||
add_subdirectory(hecl/shaderc)
|
||||
include(hecl/ApplicationTools.cmake)
|
||||
add_subdirectory(specter/shaders)
|
||||
add_subdirectory(Shaders)
|
||||
# TODO: Fix weirdness
|
||||
find_package(hsh REQUIRED)
|
||||
add_subdirectory(boo2)
|
||||
add_subdirectory(hecl)
|
||||
target_include_directories(hecl-full PRIVATE ${CMAKE_SOURCE_DIR})
|
||||
target_include_directories(hecl-light PRIVATE ${CMAKE_SOURCE_DIR})
|
||||
|
@ -294,21 +293,6 @@ if(NOT TARGET bintoc)
|
|||
find_package(hecl-bintoc REQUIRED)
|
||||
endif()
|
||||
|
||||
bintoc(CModelShaders.common.glsl.cpp Shaders/CModelShaders.common.glsl CMODELSHADERS_COMMON_GLSL)
|
||||
bintoc(CModelShaders.vert.glsl.cpp Shaders/CModelShaders.vert.glsl CMODELSHADERS_VERT_GLSL)
|
||||
bintoc(CModelShaders.frag.glsl.cpp Shaders/CModelShaders.frag.glsl CMODELSHADERS_FRAG_GLSL)
|
||||
bintoc(CModelShaders.common.hlsl.cpp Shaders/CModelShaders.common.hlsl CMODELSHADERS_COMMON_HLSL)
|
||||
bintoc(CModelShaders.vert.hlsl.cpp Shaders/CModelShaders.vert.hlsl CMODELSHADERS_VERT_HLSL)
|
||||
bintoc(CModelShaders.frag.hlsl.cpp Shaders/CModelShaders.frag.hlsl CMODELSHADERS_FRAG_HLSL)
|
||||
bintoc(CModelShaders.common.metal.cpp Shaders/CModelShaders.common.metal CMODELSHADERS_COMMON_METAL)
|
||||
bintoc(CModelShaders.vert.metal.cpp Shaders/CModelShaders.vert.metal CMODELSHADERS_VERT_METAL)
|
||||
bintoc(CModelShaders.frag.metal.cpp Shaders/CModelShaders.frag.metal CMODELSHADERS_FRAG_METAL)
|
||||
add_library(CModelShaders
|
||||
CModelShaders.common.glsl.cpp CModelShaders.vert.glsl.cpp CModelShaders.frag.glsl.cpp
|
||||
CModelShaders.common.hlsl.cpp CModelShaders.vert.hlsl.cpp CModelShaders.frag.hlsl.cpp
|
||||
CModelShaders.common.metal.cpp CModelShaders.vert.metal.cpp CModelShaders.frag.metal.cpp)
|
||||
target_link_libraries(shader_CModelShaders PUBLIC CModelShaders)
|
||||
|
||||
if(NOT TARGET atdna)
|
||||
# Import native atdna if cross-compiling
|
||||
find_package(atdna REQUIRED)
|
||||
|
@ -318,9 +302,7 @@ if(NOT TARGET atdna)
|
|||
endif()
|
||||
|
||||
add_subdirectory(amuse)
|
||||
add_subdirectory(specter)
|
||||
target_include_directories(specter PRIVATE ${CMAKE_SOURCE_DIR})
|
||||
target_link_libraries(specter PRIVATE nod)
|
||||
add_subdirectory(zeus)
|
||||
add_subdirectory(assetnameparser)
|
||||
add_compile_definitions(URDE_ZIP_INPUT_STREAM=1) # Enable CZipInputStream now that zlib header is known
|
||||
add_subdirectory(DataSpec)
|
||||
|
|
|
@ -69,10 +69,9 @@ add_library(RetroDataSpec
|
|||
AssetNameMap64.bin AssetNameMap64.cpp
|
||||
RetroMasterShader.cpp)
|
||||
|
||||
get_target_property(HECL_INCLUDES hecl-full INCLUDE_DIRECTORIES)
|
||||
target_include_directories(RetroDataSpec PUBLIC ${LIBPNG_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR}
|
||||
${HECL_INCLUDES} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR})
|
||||
target_link_libraries(RetroDataSpec PUBLIC amuse zeus nod specter squish ${PNG_LIB} ${ZLIB_LIBRARIES} lzokay logvisor)
|
||||
${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR})
|
||||
target_link_libraries(RetroDataSpec PUBLIC amuse zeus nod squish hecl-full ${PNG_LIB} ${ZLIB_LIBRARIES} lzokay logvisor)
|
||||
if(COMMAND add_sanitizers)
|
||||
add_sanitizers(RetroDataSpec)
|
||||
endif()
|
||||
|
|
|
@ -132,8 +132,8 @@ public:
|
|||
m_extraVerts[pos] = {std::make_pair(skin, 0)};
|
||||
return skin;
|
||||
}
|
||||
std::vector<std::pair<atInt16, atUint16>>& vertTrack = search->second;
|
||||
for (const std::pair<atInt16, atUint16>& s : vertTrack)
|
||||
auto& vertTrack = search->second;
|
||||
for (const auto& s : vertTrack)
|
||||
if (s.first == skin)
|
||||
return vertTrack.front().first;
|
||||
vertTrack.push_back(std::make_pair(skin, m_nextOverPos++));
|
||||
|
@ -145,8 +145,8 @@ public:
|
|||
atUint32 addedVerts = 0;
|
||||
atUint32 nextVert = 1;
|
||||
while (nextVert < m_nextOverPos) {
|
||||
for (const std::pair<atUint16, std::vector<std::pair<atInt16, atUint16>>>& ev : m_extraVerts) {
|
||||
for (const std::pair<atInt16, atUint16>& se : ev.second) {
|
||||
for (const auto& ev : m_extraVerts) {
|
||||
for (const auto& se : ev.second) {
|
||||
if (se.second == nextVert) {
|
||||
os.format(FMT_STRING(
|
||||
"bm.verts.ensure_lookup_table()\n"
|
||||
|
@ -167,7 +167,7 @@ public:
|
|||
auto search = m_extraVerts.find(pos);
|
||||
if (search == m_extraVerts.end())
|
||||
return -1;
|
||||
const std::vector<std::pair<atInt16, atUint16>>& vertTrack = search->second;
|
||||
const auto& vertTrack = search->second;
|
||||
if (vertTrack.front().first == skin)
|
||||
return pos;
|
||||
for (auto it = vertTrack.begin() + 1; it != vertTrack.end(); ++it)
|
||||
|
@ -1277,7 +1277,7 @@ bool WriteCMDL(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPath
|
|||
/* Write sections */
|
||||
athena::io::FileWriter writer(outPath.getAbsolutePath());
|
||||
head.write(writer);
|
||||
std::vector<size_t>::const_iterator padIt = paddingSizes.cbegin();
|
||||
auto padIt = paddingSizes.cbegin();
|
||||
|
||||
/* Material Sets */
|
||||
for (const MaterialSet& mset : matSets) {
|
||||
|
@ -1435,7 +1435,7 @@ bool WriteHMDLCMDL(const hecl::ProjectPath& outPath, const hecl::ProjectPath& in
|
|||
std::vector<MaterialSet> matSets;
|
||||
matSets.reserve(mesh.materialSets.size());
|
||||
|
||||
for (const std::vector<Material>& mset : mesh.materialSets) {
|
||||
for (const auto& mset : mesh.materialSets) {
|
||||
matSets.emplace_back();
|
||||
MaterialSet& targetMSet = matSets.back();
|
||||
|
||||
|
@ -1493,7 +1493,7 @@ bool WriteHMDLCMDL(const hecl::ProjectPath& outPath, const hecl::ProjectPath& in
|
|||
|
||||
/* Surfaces */
|
||||
size_t endOff = 0;
|
||||
for (const hecl::blender::HMDLBuffers::Surface& surf : bufs.m_surfaces) {
|
||||
for (const auto& surf : bufs.m_surfaces) {
|
||||
(void)surf;
|
||||
head.secSizes.push_back(64);
|
||||
paddingSizes.push_back(0);
|
||||
|
@ -1504,7 +1504,7 @@ bool WriteHMDLCMDL(const hecl::ProjectPath& outPath, const hecl::ProjectPath& in
|
|||
/* Write sections */
|
||||
athena::io::FileWriter writer(outPath.getAbsolutePath());
|
||||
head.write(writer);
|
||||
std::vector<size_t>::const_iterator padIt = paddingSizes.cbegin();
|
||||
auto padIt = paddingSizes.cbegin();
|
||||
|
||||
/* Material Sets */
|
||||
for (const MaterialSet& mset : matSets) {
|
||||
|
|
|
@ -1,20 +1,19 @@
|
|||
#include "DNACommon.hpp"
|
||||
#include "PAK.hpp"
|
||||
#include "boo/ThreadLocalPtr.hpp"
|
||||
|
||||
namespace DataSpec {
|
||||
|
||||
logvisor::Module LogDNACommon("urde::DNACommon");
|
||||
ThreadLocalPtr<SpecBase> g_curSpec;
|
||||
ThreadLocalPtr<PAKRouterBase> g_PakRouter;
|
||||
ThreadLocalPtr<hecl::blender::Token> g_ThreadBlenderToken;
|
||||
ThreadLocalPtr<hecl::Database::Project> UniqueIDBridge::s_Project;
|
||||
thread_local SpecBase* g_curSpec;
|
||||
thread_local PAKRouterBase* g_PakRouter;
|
||||
thread_local hecl::blender::Token* g_ThreadBlenderToken;
|
||||
thread_local hecl::Database::Project* UniqueIDBridge::s_Project;
|
||||
UniqueID32 UniqueID32::kInvalidId;
|
||||
|
||||
template <class IDType>
|
||||
hecl::ProjectPath UniqueIDBridge::TranslatePakIdToPath(const IDType& id, bool silenceWarnings) {
|
||||
/* Try PAKRouter first (only available at extract) */
|
||||
PAKRouterBase* pakRouter = g_PakRouter.get();
|
||||
PAKRouterBase* pakRouter = g_PakRouter;
|
||||
if (pakRouter) {
|
||||
hecl::ProjectPath path = pakRouter->getWorking(id, silenceWarnings);
|
||||
if (path)
|
||||
|
@ -22,7 +21,7 @@ hecl::ProjectPath UniqueIDBridge::TranslatePakIdToPath(const IDType& id, bool si
|
|||
}
|
||||
|
||||
/* Try project cache second (populated with paths read from YAML resources) */
|
||||
hecl::Database::Project* project = s_Project.get();
|
||||
hecl::Database::Project* project = s_Project;
|
||||
if (!project) {
|
||||
if (pakRouter) {
|
||||
if (hecl::VerbosityLevel >= 1 && !silenceWarnings && id.isValid())
|
||||
|
@ -51,7 +50,7 @@ template <class IDType>
|
|||
hecl::ProjectPath UniqueIDBridge::MakePathFromString(std::string_view str) {
|
||||
if (str.empty())
|
||||
return {};
|
||||
hecl::Database::Project* project = s_Project.get();
|
||||
hecl::Database::Project* project = s_Project;
|
||||
if (!project)
|
||||
LogDNACommon.report(logvisor::Fatal, FMT_STRING("UniqueIDBridge::setGlobalProject must be called before MakePathFromString"));
|
||||
hecl::ProjectPath path = hecl::ProjectPath(*project, str);
|
||||
|
@ -61,7 +60,7 @@ hecl::ProjectPath UniqueIDBridge::MakePathFromString(std::string_view str) {
|
|||
template hecl::ProjectPath UniqueIDBridge::MakePathFromString<UniqueID32>(std::string_view str);
|
||||
template hecl::ProjectPath UniqueIDBridge::MakePathFromString<UniqueID64>(std::string_view str);
|
||||
|
||||
void UniqueIDBridge::SetThreadProject(hecl::Database::Project& project) { s_Project.reset(&project); }
|
||||
void UniqueIDBridge::SetThreadProject(hecl::Database::Project& project) { s_Project = &project; }
|
||||
|
||||
/** PAK 32-bit Unique ID */
|
||||
template <>
|
||||
|
|
|
@ -5,16 +5,15 @@
|
|||
#include "athena/DNAYaml.hpp"
|
||||
#include "hecl/Database.hpp"
|
||||
#include "../SpecBase.hpp"
|
||||
#include "boo/ThreadLocalPtr.hpp"
|
||||
#include "zeus/CColor.hpp"
|
||||
|
||||
namespace DataSpec {
|
||||
struct SpecBase;
|
||||
|
||||
extern logvisor::Module LogDNACommon;
|
||||
extern ThreadLocalPtr<SpecBase> g_curSpec;
|
||||
extern ThreadLocalPtr<class PAKRouterBase> g_PakRouter;
|
||||
extern ThreadLocalPtr<hecl::blender::Token> g_ThreadBlenderToken;
|
||||
extern thread_local SpecBase* g_curSpec;
|
||||
extern thread_local class PAKRouterBase* g_PakRouter;
|
||||
extern thread_local hecl::blender::Token* g_ThreadBlenderToken;
|
||||
|
||||
/* This comes up a great deal */
|
||||
using BigDNA = athena::io::DNA<athena::Endian::Big>;
|
||||
|
@ -98,7 +97,7 @@ class UniqueIDBridge {
|
|||
friend class UniqueID32;
|
||||
friend class UniqueID64;
|
||||
|
||||
static ThreadLocalPtr<hecl::Database::Project> s_Project;
|
||||
static thread_local hecl::Database::Project* s_Project;
|
||||
|
||||
public:
|
||||
template <class IDType>
|
||||
|
|
|
@ -184,7 +184,7 @@ void PAKRouter<BRIDGETYPE>::build(std::vector<BRIDGETYPE>& bridges, std::functio
|
|||
}
|
||||
|
||||
/* Write catalog */
|
||||
intptr_t curBridgeIdx = reinterpret_cast<intptr_t>(m_curBridgeIdx.get());
|
||||
intptr_t curBridgeIdx = reinterpret_cast<intptr_t>(m_curBridgeIdx);
|
||||
const hecl::ProjectPath& pakPath = m_bridgePaths[curBridgeIdx].first;
|
||||
pakPath.makeDirChain(true);
|
||||
athena::io::FileWriter writer(hecl::ProjectPath(pakPath, "!catalog.yaml").getAbsolutePath());
|
||||
|
@ -194,14 +194,14 @@ void PAKRouter<BRIDGETYPE>::build(std::vector<BRIDGETYPE>& bridges, std::functio
|
|||
|
||||
template <class BRIDGETYPE>
|
||||
void PAKRouter<BRIDGETYPE>::enterPAKBridge(const BRIDGETYPE& pakBridge) {
|
||||
g_PakRouter.reset(this);
|
||||
g_PakRouter = this;
|
||||
auto pit = m_bridgePaths.begin();
|
||||
size_t bridgeIdx = 0;
|
||||
for (const BRIDGETYPE& bridge : *m_bridges) {
|
||||
if (&bridge == &pakBridge) {
|
||||
m_pak.reset(&pakBridge.getPAK());
|
||||
m_node.reset(&pakBridge.getNode());
|
||||
m_curBridgeIdx.reset(reinterpret_cast<void*>(bridgeIdx));
|
||||
m_pak = &pakBridge.getPAK();
|
||||
m_node = &pakBridge.getNode();
|
||||
m_curBridgeIdx = reinterpret_cast<void*>(bridgeIdx);
|
||||
return;
|
||||
}
|
||||
++pit;
|
||||
|
@ -234,8 +234,8 @@ hecl::ProjectPath PAKRouter<BRIDGETYPE>::getWorking(const EntryType* entry,
|
|||
if (overrideSearch != m_overrideEntries.end())
|
||||
return overrideSearch->second;
|
||||
|
||||
const PAKType* pak = m_pak.get();
|
||||
intptr_t curBridgeIdx = reinterpret_cast<intptr_t>(m_curBridgeIdx.get());
|
||||
const PAKType* pak = m_pak;
|
||||
intptr_t curBridgeIdx = reinterpret_cast<intptr_t>(m_curBridgeIdx);
|
||||
if (pak && pak->m_noShare) {
|
||||
const EntryType* singleSearch = pak->lookupEntry(entry->id);
|
||||
if (singleSearch) {
|
||||
|
@ -295,7 +295,7 @@ template <class BRIDGETYPE>
|
|||
hecl::ProjectPath PAKRouter<BRIDGETYPE>::getWorking(const EntryType* entry) const {
|
||||
if (!entry)
|
||||
return hecl::ProjectPath();
|
||||
return getWorking(entry, BRIDGETYPE::LookupExtractor(*m_node.get(), *m_pak.get(), *entry));
|
||||
return getWorking(entry, BRIDGETYPE::LookupExtractor(*m_node, *m_pak, *entry));
|
||||
}
|
||||
|
||||
template <class BRIDGETYPE>
|
||||
|
@ -314,8 +314,8 @@ hecl::ProjectPath PAKRouter<BRIDGETYPE>::getCooked(const EntryType* entry) const
|
|||
overrideSearch->second, m_dataSpec.getDataSpecEntry()));
|
||||
}
|
||||
|
||||
const PAKType* pak = m_pak.get();
|
||||
intptr_t curBridgeIdx = reinterpret_cast<intptr_t>(m_curBridgeIdx.get());
|
||||
const PAKType* pak = m_pak;
|
||||
intptr_t curBridgeIdx = reinterpret_cast<intptr_t>(m_curBridgeIdx);
|
||||
if (pak && pak->m_noShare) {
|
||||
const EntryType* singleSearch = pak->lookupEntry(entry->id);
|
||||
if (singleSearch) {
|
||||
|
@ -349,8 +349,8 @@ hecl::ProjectPath PAKRouter<BRIDGETYPE>::getCooked(const IDType& id, bool silenc
|
|||
|
||||
template <class BRIDGETYPE>
|
||||
hecl::SystemString PAKRouter<BRIDGETYPE>::getResourceRelativePath(const EntryType& a, const IDType& b) const {
|
||||
const nod::Node* node = m_node.get();
|
||||
const PAKType* pak = m_pak.get();
|
||||
const nod::Node* node = m_node;
|
||||
const PAKType* pak = m_pak;
|
||||
if (!pak)
|
||||
LogDNACommon.report(logvisor::Fatal,
|
||||
FMT_STRING("PAKRouter::enterPAKBridge() must be called before PAKRouter::getResourceRelativePath()"));
|
||||
|
@ -440,7 +440,7 @@ bool PAKRouter<BRIDGETYPE>::extractResources(const BRIDGETYPE& pakBridge, bool f
|
|||
for (unsigned w = 0; count < sz; ++w) {
|
||||
for (const auto& item : m_pak->m_firstEntries) {
|
||||
const auto* entryPtr = m_pak->lookupEntry(item);
|
||||
ResExtractor<BRIDGETYPE> extractor = BRIDGETYPE::LookupExtractor(*m_node.get(), *m_pak.get(), *entryPtr);
|
||||
ResExtractor<BRIDGETYPE> extractor = BRIDGETYPE::LookupExtractor(*m_node, *m_pak, *entryPtr);
|
||||
if (extractor.weight != w)
|
||||
continue;
|
||||
|
||||
|
@ -449,7 +449,7 @@ bool PAKRouter<BRIDGETYPE>::extractResources(const BRIDGETYPE& pakBridge, bool f
|
|||
float thisFac = ++count / fsz;
|
||||
progress(bestNameView.c_str(), thisFac);
|
||||
|
||||
const nod::Node* node = m_node.get();
|
||||
const nod::Node* node = m_node;
|
||||
|
||||
hecl::ProjectPath working = getWorking(entryPtr, extractor);
|
||||
working.makeDirChain(false);
|
||||
|
@ -497,8 +497,8 @@ const typename BRIDGETYPE::PAKType::Entry* PAKRouter<BRIDGETYPE>::lookupEntry(co
|
|||
if (!m_bridges)
|
||||
LogDNACommon.report(logvisor::Fatal, FMT_STRING("PAKRouter::build() must be called before PAKRouter::lookupEntry()"));
|
||||
|
||||
const PAKType* pak = m_pak.get();
|
||||
const nod::Node* node = m_node.get();
|
||||
const PAKType* pak = m_pak;
|
||||
const nod::Node* node = m_node;
|
||||
if (pak) {
|
||||
const EntryType* ent = pak->lookupEntry(entry);
|
||||
if (ent) {
|
||||
|
@ -659,7 +659,7 @@ void PAKRouter<BRIDGETYPE>::enumerateResources(const std::function<bool(const En
|
|||
|
||||
template <class BRIDGETYPE>
|
||||
bool PAKRouter<BRIDGETYPE>::mreaHasDupeResources(const IDType& id) const {
|
||||
const PAKType* pak = m_pak.get();
|
||||
const PAKType* pak = m_pak;
|
||||
if (!pak)
|
||||
LogDNACommon.report(logvisor::Fatal,
|
||||
FMT_STRING("PAKRouter::enterPAKBridge() must be called before PAKRouter::mreaHasDupeResources()"));
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
|
||||
#include "DataSpec/DNACommon/DNACommon.hpp"
|
||||
|
||||
#include <boo/ThreadLocalPtr.hpp>
|
||||
#include <zeus/CMatrix4f.hpp>
|
||||
#include <zeus/Global.hpp>
|
||||
|
||||
|
@ -153,13 +152,13 @@ public:
|
|||
private:
|
||||
const std::vector<BRIDGETYPE>* m_bridges = nullptr;
|
||||
std::vector<std::pair<hecl::ProjectPath, hecl::ProjectPath>> m_bridgePaths;
|
||||
ThreadLocalPtr<void> m_curBridgeIdx;
|
||||
static thread_local void* m_curBridgeIdx;
|
||||
const hecl::ProjectPath& m_gameWorking;
|
||||
const hecl::ProjectPath& m_gameCooked;
|
||||
hecl::ProjectPath m_sharedWorking;
|
||||
hecl::ProjectPath m_sharedCooked;
|
||||
ThreadLocalPtr<const PAKType> m_pak;
|
||||
ThreadLocalPtr<const nod::Node> m_node;
|
||||
static thread_local const PAKType* m_pak;
|
||||
static thread_local const nod::Node* m_node;
|
||||
std::unordered_map<IDType, std::pair<size_t, const EntryType*>> m_uniqueEntries;
|
||||
std::unordered_map<IDType, std::pair<size_t, const EntryType*>> m_sharedEntries;
|
||||
std::unordered_map<IDType, hecl::ProjectPath> m_overrideEntries;
|
||||
|
@ -179,7 +178,7 @@ public:
|
|||
void build(std::vector<BRIDGETYPE>& bridges, std::function<void(float)> progress);
|
||||
|
||||
void enterPAKBridge(const BRIDGETYPE& pakBridge);
|
||||
const BRIDGETYPE& getCurrentBridge() const { return (*m_bridges)[reinterpret_cast<intptr_t>(m_curBridgeIdx.get())]; }
|
||||
const BRIDGETYPE& getCurrentBridge() const { return (*m_bridges)[reinterpret_cast<intptr_t>(m_curBridgeIdx)]; }
|
||||
|
||||
using PAKRouterBase::getWorking;
|
||||
hecl::ProjectPath getWorking(const EntryType* entry, const ResExtractor<BRIDGETYPE>& extractor) const;
|
||||
|
@ -231,4 +230,8 @@ public:
|
|||
bool mreaHasDupeResources(const IDType& id) const;
|
||||
};
|
||||
|
||||
template <class BRIDGETYPE> thread_local void* PAKRouter<BRIDGETYPE>::m_curBridgeIdx;
|
||||
template <class BRIDGETYPE> thread_local const typename PAKRouter<BRIDGETYPE>::PAKType* PAKRouter<BRIDGETYPE>::m_pak;
|
||||
template <class BRIDGETYPE> thread_local const nod::Node* PAKRouter<BRIDGETYPE>::m_node;
|
||||
|
||||
} // namespace DataSpec
|
||||
|
|
|
@ -265,7 +265,7 @@ bool MLVL::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPat
|
|||
|
||||
/* Gather memory relays, scans, and dependencies */
|
||||
{
|
||||
g_ThreadBlenderToken.reset(&btok);
|
||||
g_ThreadBlenderToken = &btok;
|
||||
std::vector<hecl::ProjectPath> depPaths;
|
||||
std::vector<hecl::ProjectPath> lazyPaths;
|
||||
for (std::unique_ptr<IScriptObject>& obj : layer.objects) {
|
||||
|
|
|
@ -6,12 +6,12 @@
|
|||
namespace DataSpec::DNAMP1 {
|
||||
struct Actor : IScriptObject {
|
||||
AT_DECL_DNA_YAMLV
|
||||
String<-1> name SO_NAME_SPECPROP();
|
||||
Value<atVec3f> location SO_LOCATION_SPECPROP();
|
||||
Value<atVec3f> orientation SO_ORIENTATION_SPECPROP();
|
||||
Value<atVec3f> scale SO_SCALE_SPECPROP();
|
||||
Value<atVec3f> collisionExtent SO_COLLISION_EXTENT_SPECPROP();
|
||||
Value<atVec3f> collisionOffset SO_COLLISION_OFFSET_SPECPROP();
|
||||
String<-1> name;
|
||||
Value<atVec3f> location;
|
||||
Value<atVec3f> orientation;
|
||||
Value<atVec3f> scale;
|
||||
Value<atVec3f> collisionExtent;
|
||||
Value<atVec3f> collisionOffset;
|
||||
Value<float> mass;
|
||||
Value<float> zMomentum;
|
||||
HealthInfo healthInfo;
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
#include "../DNAMP1.hpp"
|
||||
#include "../SAVW.hpp"
|
||||
#include "zeus/CAABox.hpp"
|
||||
#include "specter/genie.hpp"
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
#pragma once
|
||||
|
||||
#include "../../DNACommon/DNACommon.hpp"
|
||||
#include "../DNAMP1.hpp"
|
||||
#include "../SAVW.hpp"
|
||||
#include "specter/genie.hpp"
|
||||
#include "DataSpec/DNACommon/DNACommon.hpp"
|
||||
#include "DataSpec/DNAMP1/DNAMP1.hpp"
|
||||
#include "DataSpec/DNAMP1/SAVW.hpp"
|
||||
|
||||
namespace DataSpec::DNAMP1 {
|
||||
|
||||
|
@ -49,7 +48,7 @@ enum class EPickupType : atUint32 {
|
|||
World = 38,
|
||||
Spirit = 39,
|
||||
Newborn = 40
|
||||
} SPECTER_ENUM("Pickup Type", "", EPickupType);
|
||||
};
|
||||
|
||||
enum class ESpecialFunctionType : atUint32 {
|
||||
What,
|
||||
|
@ -85,7 +84,7 @@ enum class ESpecialFunctionType : atUint32 {
|
|||
Ending,
|
||||
FusionRelay,
|
||||
WeaponSwitch // PAL Only
|
||||
} SPECTER_ENUM("Special Function", "", ESpecialFunctionType);
|
||||
};
|
||||
|
||||
struct AnimationParameters : BigDNA {
|
||||
AT_DECL_DNA_YAML
|
||||
|
@ -211,9 +210,9 @@ struct GrappleParameters : BigDNA {
|
|||
struct HealthInfo : BigDNA {
|
||||
AT_DECL_DNA_YAML
|
||||
Value<atUint32> propertyCount;
|
||||
Value<float> health SPECTER_PROPERTY("Health", "Base health for object");
|
||||
Value<float> knockbackResistance SPECTER_PROPERTY("Knockback Resistance", "");
|
||||
} SPECTER_PROPERTY("Health Info", "");
|
||||
Value<float> health;
|
||||
Value<float> knockbackResistance;
|
||||
};
|
||||
|
||||
struct LightParameters : BigDNA {
|
||||
AT_DECL_DNA_YAML
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#include "DataSpec/DNAMP1/Tweaks/CTweakGame.hpp"
|
||||
#include "Runtime/Camera/CCameraManager.hpp"
|
||||
|
||||
#include <hecl/CVar.hpp>
|
||||
#include <hecl/CVarManager.hpp>
|
||||
|
|
|
@ -97,7 +97,7 @@ bool SpecBase::canExtract(const ExtractPassInfo& info, std::vector<ExtractReport
|
|||
|
||||
void SpecBase::doExtract(const ExtractPassInfo& info, const hecl::MultiProgressPrinter& progress) {
|
||||
setThreadProject();
|
||||
DataSpec::g_curSpec.reset(this);
|
||||
DataSpec::g_curSpec = this;
|
||||
if (!Blender::BuildMasterShader(m_masterShader))
|
||||
Log.report(logvisor::Fatal, FMT_STRING("Unable to build master shader blend"));
|
||||
if (m_isWii) {
|
||||
|
@ -196,7 +196,7 @@ const hecl::Database::DataSpecEntry* SpecBase::overrideDataSpec(const hecl::Proj
|
|||
void SpecBase::doCook(const hecl::ProjectPath& path, const hecl::ProjectPath& cookedPath, bool fast,
|
||||
hecl::blender::Token& btok, FCookProgress progress) {
|
||||
cookedPath.makeDirChain(false);
|
||||
DataSpec::g_curSpec.reset(this);
|
||||
DataSpec::g_curSpec = this;
|
||||
|
||||
hecl::ProjectPath asBlend;
|
||||
if (path.getPathType() == hecl::ProjectPath::Type::Glob)
|
||||
|
@ -386,8 +386,8 @@ void SpecBase::flattenDependenciesBlend(const hecl::ProjectPath& in, std::vector
|
|||
|
||||
void SpecBase::flattenDependencies(const hecl::ProjectPath& path, std::vector<hecl::ProjectPath>& pathsOut,
|
||||
hecl::blender::Token& btok, int charIdx) {
|
||||
DataSpec::g_curSpec.reset(this);
|
||||
g_ThreadBlenderToken.reset(&btok);
|
||||
DataSpec::g_curSpec = this;
|
||||
g_ThreadBlenderToken = &btok;
|
||||
|
||||
hecl::ProjectPath asBlend;
|
||||
if (path.getPathType() == hecl::ProjectPath::Type::Glob)
|
||||
|
@ -408,13 +408,13 @@ void SpecBase::flattenDependencies(const hecl::ProjectPath& path, std::vector<he
|
|||
void SpecBase::flattenDependencies(const UniqueID32& id, std::vector<hecl::ProjectPath>& pathsOut, int charIdx) {
|
||||
hecl::ProjectPath path = UniqueIDBridge::TranslatePakIdToPath(id);
|
||||
if (path)
|
||||
flattenDependencies(path, pathsOut, *g_ThreadBlenderToken.get(), charIdx);
|
||||
flattenDependencies(path, pathsOut, *g_ThreadBlenderToken, charIdx);
|
||||
}
|
||||
|
||||
void SpecBase::flattenDependencies(const UniqueID64& id, std::vector<hecl::ProjectPath>& pathsOut, int charIdx) {
|
||||
hecl::ProjectPath path = UniqueIDBridge::TranslatePakIdToPath(id);
|
||||
if (path)
|
||||
flattenDependencies(path, pathsOut, *g_ThreadBlenderToken.get(), charIdx);
|
||||
flattenDependencies(path, pathsOut, *g_ThreadBlenderToken, charIdx);
|
||||
}
|
||||
|
||||
bool SpecBase::canPackage(const hecl::ProjectPath& path) {
|
||||
|
|
|
@ -72,7 +72,7 @@ elseif(UNIX)
|
|||
set(URDE_PLAT_LIBS rt)
|
||||
endif()
|
||||
|
||||
add_executable(urde WIN32 MACOSX_BUNDLE
|
||||
add_executable(urde-old WIN32 MACOSX_BUNDLE
|
||||
main.cpp ${PLAT_SRCS}
|
||||
Space.hpp Space.cpp
|
||||
SplashScreen.hpp SplashScreen.cpp
|
||||
|
@ -85,40 +85,40 @@ add_executable(urde WIN32 MACOSX_BUNDLE
|
|||
Resource.hpp Resource.cpp
|
||||
Camera.hpp Camera.cpp
|
||||
GameMode.hpp GameMode.cpp)
|
||||
target_atdna(urde atdna_Space.cpp Space.hpp)
|
||||
target_atdna(urde atdna_ResourceBrowser.cpp ResourceBrowser.hpp)
|
||||
target_atdna(urde atdna_ModelViewer.cpp ModelViewer.hpp)
|
||||
target_atdna(urde atdna_ParticleEditor.cpp ParticleEditor.hpp)
|
||||
target_atdna(urde atdna_InformationCenter.cpp InformationCenter.hpp)
|
||||
target_atdna(urde atdna_GameMode.cpp GameMode.hpp)
|
||||
target_atdna(urde-old atdna_Space.cpp Space.hpp)
|
||||
target_atdna(urde-old atdna_ResourceBrowser.cpp ResourceBrowser.hpp)
|
||||
target_atdna(urde-old atdna_ModelViewer.cpp ModelViewer.hpp)
|
||||
target_atdna(urde-old atdna_ParticleEditor.cpp ParticleEditor.hpp)
|
||||
target_atdna(urde-old atdna_InformationCenter.cpp InformationCenter.hpp)
|
||||
target_atdna(urde-old atdna_GameMode.cpp GameMode.hpp)
|
||||
|
||||
target_compile_definitions(urde PUBLIC URDE_DLPACKAGE="${URDE_DLPACKAGE}")
|
||||
target_compile_definitions(urde-old PUBLIC URDE_DLPACKAGE="${URDE_DLPACKAGE}")
|
||||
|
||||
target_include_directories(urde PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_BINARY_DIR})
|
||||
target_include_directories(urde-old PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_BINARY_DIR})
|
||||
|
||||
target_link_libraries(urde
|
||||
target_link_libraries(urde-old
|
||||
UrdeIcons
|
||||
UrdeBadging
|
||||
RuntimeCommon
|
||||
${URDE_PLAT_LIBS})
|
||||
if(COMMAND add_sanitizers)
|
||||
add_sanitizers(urde)
|
||||
add_sanitizers(urde-old)
|
||||
endif()
|
||||
|
||||
set_target_properties(urde PROPERTIES
|
||||
set_target_properties(urde-old PROPERTIES
|
||||
MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_BINARY_DIR}/Info.plist"
|
||||
MACOSX_BUNDLE_BUNDLE_NAME "urde")
|
||||
|
||||
if (NOT WINDOWS_STORE)
|
||||
if(APPLE)
|
||||
add_custom_command(TARGET urde POST_BUILD
|
||||
add_custom_command(TARGET urde-old POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:visigen> $<TARGET_FILE_DIR:urde>)
|
||||
add_custom_command(TARGET urde POST_BUILD
|
||||
add_custom_command(TARGET urde-old POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:hecl> $<TARGET_FILE_DIR:urde>)
|
||||
endif()
|
||||
add_dependencies(urde visigen hecl)
|
||||
add_dependencies(urde-old visigen hecl)
|
||||
else()
|
||||
set_property(TARGET urde PROPERTY VS_WINRT_COMPONENT TRUE)
|
||||
set_property(TARGET urde-old PROPERTY VS_WINRT_COMPONENT TRUE)
|
||||
# This should match the Package.appxmanifest
|
||||
set_property(TARGET urde PROPERTY VS_WINDOWS_TARGET_PLATFORM_MIN_VERSION "10.0.14393.0")
|
||||
set_property(TARGET urde-old PROPERTY VS_WINDOWS_TARGET_PLATFORM_MIN_VERSION "10.0.14393.0")
|
||||
endif()
|
||||
|
|
|
@ -40,4 +40,3 @@ bintoc(badge.cpp ${CMAKE_CURRENT_BINARY_DIR}/badge.bin URDE_BADGE)
|
|||
add_library(UrdeBadging
|
||||
badge.cpp badge.bin
|
||||
Badging.hpp Badging.cpp)
|
||||
target_link_libraries(UrdeBadging PUBLIC specter)
|
||||
|
|
|
@ -60,4 +60,3 @@ endif()
|
|||
|
||||
bintoc(icons_dat.cpp ${CMAKE_CURRENT_BINARY_DIR}/icons.bin URDE_ICONS)
|
||||
add_library(UrdeIcons icons.cpp icons.hpp icons.bin icons_dat.cpp)
|
||||
target_link_libraries(UrdeIcons PUBLIC specter)
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit c595cf725f657f3542264d7a244c14716ec41bfa
|
||||
Subproject commit 2b16c090215130336b401bb5db9831dbc8db78fa
|
|
@ -3,11 +3,13 @@ add_library(NESEmulator CNESEmulator.hpp CNESEmulator.cpp CNESShader.hpp CNESSha
|
|||
apu.c fixNES/audio_fds.c fixNES/audio_mmc5.c fixNES/audio_vrc6.c fixNES/audio_vrc7.c
|
||||
fixNES/audio_n163.c fixNES/audio_s5b.c fixNES/cpu.c ppu.c fixNES/mem.c fixNES/input.c
|
||||
fixNES/mapper.c fixNES/mapperList.c fixNES/fm2play.c fixNES/vrc_irq.c ${MAPPER_SRCS})
|
||||
hsh_sources(CNESShader.cpp)
|
||||
target_include_directories(NESEmulator PRIVATE ${CMAKE_SOURCE_DIR}/DataSpec ${CMAKE_SOURCE_DIR}/Runtime
|
||||
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_compile_definitions(NESEmulator PRIVATE COL_32BIT=1 COL_TEX_BSWAP=1)
|
||||
target_link_libraries(NESEmulator boo hecl-full RuntimeCommon ${HECL_APPLICATION_REPS_TARGETS_LIST})
|
||||
target_link_libraries(NESEmulator PUBLIC hecl-full RuntimeCommon)
|
||||
if (NOT MSVC)
|
||||
target_compile_options(NESEmulator PRIVATE -Wno-implicit-fallthrough -Wno-format -Wno-pointer-compare
|
||||
-Wno-memset-elt-size)
|
||||
endif()
|
||||
endif()
|
||||
target_hsh(NESEmulator)
|
||||
|
|
|
@ -260,31 +260,16 @@ void CNESEmulator::InitializeEmulator() {
|
|||
// mainLoopRuns = nesPAL ? DOTS*ppuCycleTimer : DOTS*ppuCycleTimer;
|
||||
// mainLoopPos = mainLoopRuns;
|
||||
|
||||
CGraphics::CommitResources([this](boo::IGraphicsDataFactory::Context& ctx) {
|
||||
// Nearest-neighbor FTW!
|
||||
m_texture = ctx.newDynamicTexture(VISIBLE_DOTS, linesToDraw, boo::TextureFormat::RGBA8,
|
||||
boo::TextureClampMode::ClampToEdgeNearest);
|
||||
if (ctx.platform() == boo::IGraphicsDataFactory::Platform::OpenGL) {
|
||||
Vert verts[4] = {
|
||||
{{-1.f, -1.f, 0.f}, {0.f, 1.f}},
|
||||
{{-1.f, 1.f, 0.f}, {0.f, 0.f}},
|
||||
{{1.f, -1.f, 0.f}, {1.f, 1.f}},
|
||||
{{1.f, 1.f, 0.f}, {1.f, 0.f}},
|
||||
};
|
||||
m_vbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, verts, sizeof(Vert), 4);
|
||||
} else {
|
||||
Vert verts[4] = {
|
||||
{{-1.f, 1.f, 0.f}, {0.f, 1.f}},
|
||||
{{-1.f, -1.f, 0.f}, {0.f, 0.f}},
|
||||
{{1.f, 1.f, 0.f}, {1.f, 1.f}},
|
||||
{{1.f, -1.f, 0.f}, {1.f, 0.f}},
|
||||
};
|
||||
m_vbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, verts, sizeof(Vert), 4);
|
||||
}
|
||||
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
|
||||
m_shadBind = CNESShader::BuildShaderDataBinding(ctx, m_vbo, m_uniBuf, m_texture);
|
||||
return true;
|
||||
} BooTrace);
|
||||
m_texture = hsh::create_dynamic_texture2d<float>({VISIBLE_DOTS, linesToDraw}, hsh::RGBA8_UNORM, 1);
|
||||
constexpr TexUVVert verts[4] = {
|
||||
{{-1.f, -1.f, 0.f}, {0.f, 1.f}},
|
||||
{{-1.f, 1.f, 0.f}, {0.f, 0.f}},
|
||||
{{1.f, -1.f, 0.f}, {1.f, 1.f}},
|
||||
{{1.f, 1.f, 0.f}, {1.f, 0.f}},
|
||||
};
|
||||
m_vbo = hsh::create_vertex_buffer<TexUVVert>(verts);
|
||||
m_uniBuf = hsh::create_dynamic_uniform_buffer<ViewBlock>();
|
||||
m_shadBind = CNESShader::BuildShaderDataBinding(m_vbo.get(), m_uniBuf.get(), m_texture.get());
|
||||
|
||||
// double useFreq = 223740;
|
||||
double useFreq = apuGetFrequency();
|
||||
|
@ -377,7 +362,7 @@ int CNESEmulator::audioUpdate() {
|
|||
|
||||
static constexpr uint32_t AudioFrameSz = 2 * sizeof(int16_t);
|
||||
|
||||
size_t CNESEmulator::supplyAudio(boo::IAudioVoice& voice, size_t frames, int16_t* data) {
|
||||
size_t CNESEmulator::supplyAudio(boo2::IAudioVoice& voice, size_t frames, int16_t* data) {
|
||||
uint32_t remFrames = uint32_t(frames);
|
||||
while (remFrames) {
|
||||
if (m_posInTailBuf == apuGetMaxBufSize()) {
|
||||
|
@ -413,7 +398,7 @@ void CNESEmulator::NesEmuMainLoop(bool forceDraw) {
|
|||
emuMainTimesSkipped++;
|
||||
#endif
|
||||
// printf("LC RENDER: %d\n", loopCount);
|
||||
m_texture->load(textureImage, visibleImg);
|
||||
m_texture.load(textureImage, visibleImg);
|
||||
emuRenderFrame = false;
|
||||
break;
|
||||
}
|
||||
|
@ -605,11 +590,11 @@ void CNESEmulator::ProcessUserInput(const CFinalInput& input, int) {
|
|||
if (GetPasswordEntryState() != EPasswordEntryState::NotPasswordScreen) {
|
||||
// Don't swap A/B
|
||||
inValReads[BUTTON_A] = input.DA() || input.DSpecialKey(boo::ESpecialKey::Enter) ||
|
||||
input.DMouseButton(boo::EMouseButton::Primary);
|
||||
inValReads[BUTTON_B] = input.DB() || input.DSpecialKey(boo::ESpecialKey::Esc);
|
||||
input.DMouseButton(boo2::MouseButton::Primary);
|
||||
inValReads[BUTTON_B] = input.DB() || input.DSpecialKey(boo2::Keycode::ESC);
|
||||
} else {
|
||||
// Prime controls (B jumps, A shoots)
|
||||
inValReads[BUTTON_B] = input.DA() || input.DY() || input.DMouseButton(boo::EMouseButton::Primary);
|
||||
inValReads[BUTTON_B] = input.DA() || input.DY() || input.DMouseButton(boo2::MouseButton::Primary);
|
||||
inValReads[BUTTON_A] = input.DB() || input.DX() || input.DKey(' ');
|
||||
}
|
||||
|
||||
|
@ -618,7 +603,7 @@ void CNESEmulator::ProcessUserInput(const CFinalInput& input, int) {
|
|||
inValReads[BUTTON_LEFT] = input.DDPLeft() || input.DLALeft();
|
||||
inValReads[BUTTON_RIGHT] = input.DDPRight() || input.DLARight();
|
||||
inValReads[BUTTON_SELECT] = input.DZ() || input.DKey('\t');
|
||||
inValReads[BUTTON_START] = input.DStart() || input.DSpecialKey(boo::ESpecialKey::Esc);
|
||||
inValReads[BUTTON_START] = input.DStart() || input.DSpecialKey(boo2::Keycode::ESC);
|
||||
}
|
||||
|
||||
bool CNESEmulator::CheckForGameOver(const u8* vram, u8* passwordOut) {
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
#include "RetroTypes.hpp"
|
||||
#include "zeus/CColor.hpp"
|
||||
#include "boo/graphicsdev/IGraphicsDataFactory.hpp"
|
||||
#include "boo/audiodev/IAudioVoice.hpp"
|
||||
#include "boo2/audiodev/IAudioVoice.hpp"
|
||||
#include "zeus/CMatrix4f.hpp"
|
||||
#include "Graphics/CGraphics.hpp"
|
||||
|
||||
namespace urde {
|
||||
struct CFinalInput;
|
||||
|
@ -14,7 +14,7 @@ namespace MP1 {
|
|||
|
||||
#define NUM_AUDIO_BUFFERS 4
|
||||
|
||||
class CNESEmulator final : public boo::IAudioVoiceCallback {
|
||||
class CNESEmulator final : public boo2::IAudioVoiceCallback {
|
||||
public:
|
||||
enum class EPasswordEntryState { NotPasswordScreen, NotEntered, Entered };
|
||||
|
||||
|
@ -24,20 +24,10 @@ private:
|
|||
std::unique_ptr<u8[]> m_nesEmuPBuf;
|
||||
std::shared_ptr<IDvdRequest> m_dvdReq;
|
||||
|
||||
struct Vert {
|
||||
zeus::CVector3f m_pos;
|
||||
zeus::CVector2f m_uv;
|
||||
};
|
||||
|
||||
struct Uniform {
|
||||
zeus::CMatrix4f m_matrix;
|
||||
zeus::CColor m_color;
|
||||
};
|
||||
|
||||
boo::ObjToken<boo::ITextureD> m_texture;
|
||||
boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
|
||||
boo::ObjToken<boo::IGraphicsBufferS> m_vbo;
|
||||
boo::ObjToken<boo::IShaderDataBinding> m_shadBind;
|
||||
hsh::dynamic_owner<hsh::texture2d> m_texture;
|
||||
hsh::dynamic_owner<hsh::uniform_buffer<ViewBlock>> m_uniBuf;
|
||||
hsh::owner<hsh::vertex_buffer<TexUVVert>> m_vbo;
|
||||
hsh::binding m_shadBind;
|
||||
|
||||
std::unique_ptr<u8[]> m_audioBufBlock;
|
||||
u8* m_audioBufs[NUM_AUDIO_BUFFERS];
|
||||
|
@ -46,7 +36,7 @@ private:
|
|||
uint32_t m_procBufs = NUM_AUDIO_BUFFERS;
|
||||
uint32_t m_posInHeadBuf = 0;
|
||||
uint32_t m_posInTailBuf = 0;
|
||||
boo::ObjToken<boo::IAudioVoice> m_booVoice;
|
||||
boo2::ObjToken<boo2::IAudioVoice> m_booVoice;
|
||||
|
||||
// void* x4_loadBuf;
|
||||
// void* x8_rom;
|
||||
|
@ -81,8 +71,8 @@ public:
|
|||
EPasswordEntryState GetPasswordEntryState() const { return x34_passwordEntryState; }
|
||||
|
||||
int audioUpdate();
|
||||
void preSupplyAudio(boo::IAudioVoice& voice, double dt) {}
|
||||
size_t supplyAudio(boo::IAudioVoice& voice, size_t frames, int16_t* data);
|
||||
void preSupplyAudio(boo2::IAudioVoice& voice, double dt) override {}
|
||||
size_t supplyAudio(boo2::IAudioVoice& voice, size_t frames, int16_t* data) override;
|
||||
};
|
||||
|
||||
} // namespace MP1
|
||||
|
|
|
@ -1,24 +1,22 @@
|
|||
#include "CNESShader.hpp"
|
||||
#include "Graphics/CGraphics.hpp"
|
||||
#include "hecl/Pipeline.hpp"
|
||||
|
||||
#include "CNESShader.cpp.hshhead"
|
||||
|
||||
namespace urde::MP1 {
|
||||
|
||||
boo::ObjToken<boo::IShaderPipeline> CNESShader::g_Pipeline;
|
||||
using namespace hsh::pipeline;
|
||||
|
||||
void CNESShader::Initialize() { g_Pipeline = hecl::conv->convert(Shader_CNESShader{}); }
|
||||
struct NESPipeline : public pipeline<color_attachment<>> {
|
||||
NESPipeline(hsh::vertex_buffer<TexUVVert> vbo, hsh::uniform_buffer<ViewBlock> uniBuf, hsh::texture2d tex) {
|
||||
position = uniBuf->m_mv * hsh::float4(vbo->m_pos, 1.0);
|
||||
color_out[0] = uniBuf->m_color * tex.sample<float>(vbo->m_uv);
|
||||
}
|
||||
};
|
||||
|
||||
boo::ObjToken<boo::IShaderDataBinding> CNESShader::BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
boo::ObjToken<boo::IGraphicsBufferS> vbo,
|
||||
boo::ObjToken<boo::IGraphicsBufferD> uniBuf,
|
||||
boo::ObjToken<boo::ITextureD> tex) {
|
||||
boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {uniBuf.get()};
|
||||
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
|
||||
boo::ObjToken<boo::ITexture> texs[] = {tex.get()};
|
||||
return ctx.newShaderDataBinding(g_Pipeline, vbo.get(), nullptr, nullptr, 1, bufs, stages, nullptr, nullptr, 1, texs,
|
||||
nullptr, nullptr);
|
||||
void CNESShader::BuildShaderDataBinding(hsh::binding& binding, hsh::vertex_buffer<TexUVVert> vbo,
|
||||
hsh::uniform_buffer<ViewBlock> uniBuf, hsh::texture2d tex) {
|
||||
binding.hsh_bind(NESPipeline(vbo, uniBuf, tex));
|
||||
}
|
||||
|
||||
void CNESShader::Shutdown() { g_Pipeline.reset(); }
|
||||
|
||||
} // namespace urde::MP1
|
||||
|
|
|
@ -1,20 +1,14 @@
|
|||
#pragma once
|
||||
|
||||
#include "boo/graphicsdev/IGraphicsDataFactory.hpp"
|
||||
#include "hsh/hsh.h"
|
||||
#include "Graphics/CGraphics.hpp"
|
||||
|
||||
namespace urde::MP1 {
|
||||
|
||||
class CNESShader {
|
||||
public:
|
||||
static void Initialize();
|
||||
static void Shutdown();
|
||||
|
||||
static boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
boo::ObjToken<boo::IGraphicsBufferS> vbo,
|
||||
boo::ObjToken<boo::IGraphicsBufferD> uniBuf,
|
||||
boo::ObjToken<boo::ITextureD> tex);
|
||||
|
||||
static boo::ObjToken<boo::IShaderPipeline> g_Pipeline;
|
||||
static void BuildShaderDataBinding(hsh::binding& binding, hsh::vertex_buffer<TexUVVert> vbo,
|
||||
hsh::uniform_buffer<ViewBlock> uniBuf, hsh::texture2d tex);
|
||||
};
|
||||
|
||||
} // namespace urde::MP1
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
#include "Runtime/GCNTypes.hpp"
|
||||
#include "Runtime/RetroTypes.hpp"
|
||||
|
||||
#include <amuse/amuse.hpp>
|
||||
#include <boo/audiodev/IAudioVoiceEngine.hpp>
|
||||
#include <zeus/CVector3f.hpp>
|
||||
#include "amuse/amuse.hpp"
|
||||
#include "boo2/audiodev/IAudioVoiceEngine.hpp"
|
||||
#include "zeus/CVector3f.hpp"
|
||||
|
||||
namespace urde {
|
||||
class CAudioGroupSet;
|
||||
|
@ -21,7 +21,7 @@ public:
|
|||
|
||||
private:
|
||||
static CAudioSys* g_SharedSys;
|
||||
boo::IAudioVoiceEngine* m_voiceEngine;
|
||||
boo2::IAudioVoiceEngine* m_voiceEngine;
|
||||
amuse::Engine m_engine;
|
||||
static void _UpdateVolume();
|
||||
|
||||
|
@ -38,7 +38,7 @@ public:
|
|||
bool x28_important; // Can't be allocated over, regardless of priority
|
||||
u8 x29_prio;
|
||||
};
|
||||
CAudioSys(boo::IAudioVoiceEngine* voiceEngine, amuse::IBackendVoiceAllocator& backend, u8, u8, u8, u8, u32)
|
||||
CAudioSys(boo2::IAudioVoiceEngine* voiceEngine, amuse::IBackendVoiceAllocator& backend, u8, u8, u8, u8, u32)
|
||||
: m_voiceEngine(voiceEngine), m_engine(backend) {
|
||||
g_SharedSys = this;
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ public:
|
|||
|
||||
static void AddAudioGroup(const amuse::AudioGroupData& data) { g_SharedSys->m_engine.addAudioGroup(data); }
|
||||
static void RemoveAudioGroup(const amuse::AudioGroupData& data) { g_SharedSys->m_engine.removeAudioGroup(data); }
|
||||
static boo::IAudioVoiceEngine* GetVoiceEngine() { return g_SharedSys->m_voiceEngine; }
|
||||
static boo2::IAudioVoiceEngine* GetVoiceEngine() { return g_SharedSys->m_voiceEngine; }
|
||||
static amuse::Engine& GetAmuseEngine() { return g_SharedSys->m_engine; }
|
||||
static void SetSurroundMode(ESurroundModes mode) {}
|
||||
static TLockedToken<CAudioGroupSet> FindGroupSet(std::string_view name);
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace urde {
|
|||
|
||||
#define RSF_BUFFER_SIZE 0x20000
|
||||
|
||||
CStaticAudioPlayer::CStaticAudioPlayer(boo::IAudioVoiceEngine& engine, std::string_view path, int loopStart,
|
||||
CStaticAudioPlayer::CStaticAudioPlayer(boo2::IAudioVoiceEngine& engine, std::string_view path, int loopStart,
|
||||
int loopEnd)
|
||||
: x0_path(path)
|
||||
, x1c_loopStartSamp(loopStart & 0xfffffffe)
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
|
||||
#include "g721.h"
|
||||
|
||||
#include <boo/audiodev/IAudioVoice.hpp>
|
||||
#include <boo/audiodev/IAudioVoiceEngine.hpp>
|
||||
#include "boo2/audiodev/IAudioVoice.hpp"
|
||||
#include "boo2/audiodev/IAudioVoiceEngine.hpp"
|
||||
|
||||
namespace urde {
|
||||
class IDvdRequest;
|
||||
|
@ -42,10 +42,10 @@ class CStaticAudioPlayer {
|
|||
return val;
|
||||
}
|
||||
|
||||
struct AudioVoiceCallback : boo::IAudioVoiceCallback {
|
||||
struct AudioVoiceCallback : boo2::IAudioVoiceCallback {
|
||||
CStaticAudioPlayer& m_parent;
|
||||
void preSupplyAudio(boo::IAudioVoice&, double) override {}
|
||||
size_t supplyAudio(boo::IAudioVoice& voice, size_t frames, int16_t* data) override {
|
||||
void preSupplyAudio(boo2::IAudioVoice&, double) override {}
|
||||
size_t supplyAudio(boo2::IAudioVoice& voice, size_t frames, int16_t* data) override {
|
||||
if (m_parent.IsReady()) {
|
||||
m_parent.x38_dvdRequests.clear();
|
||||
m_parent.Decode(data, frames);
|
||||
|
@ -55,10 +55,10 @@ class CStaticAudioPlayer {
|
|||
}
|
||||
explicit AudioVoiceCallback(CStaticAudioPlayer& p) : m_parent(p) {}
|
||||
} m_voiceCallback;
|
||||
boo::ObjToken<boo::IAudioVoice> m_voice;
|
||||
boo2::ObjToken<boo2::IAudioVoice> m_voice;
|
||||
|
||||
public:
|
||||
CStaticAudioPlayer(boo::IAudioVoiceEngine& engine, std::string_view path, int loopStart, int loopEnd);
|
||||
CStaticAudioPlayer(boo2::IAudioVoiceEngine& engine, std::string_view path, int loopStart, int loopEnd);
|
||||
CStaticAudioPlayer(std::string_view path, int loopStart, int loopEnd)
|
||||
: CStaticAudioPlayer(*CAudioSys::GetVoiceEngine(), path, loopStart, loopEnd) {}
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ struct SDSPStreamInfo {
|
|||
explicit SDSPStreamInfo(const CDSPStreamManager& stream);
|
||||
};
|
||||
|
||||
struct SDSPStream : boo::IAudioVoiceCallback {
|
||||
struct SDSPStream : boo2::IAudioVoiceCallback {
|
||||
bool x0_active;
|
||||
bool x1_oneshot;
|
||||
s32 x4_ownerId;
|
||||
|
@ -155,7 +155,7 @@ struct SDSPStream : boo::IAudioVoiceCallback {
|
|||
s16 m_prev1 = 0;
|
||||
s16 m_prev2 = 0;
|
||||
|
||||
void preSupplyAudio(boo::IAudioVoice&, double) override {}
|
||||
void preSupplyAudio(boo2::IAudioVoice&, double) override {}
|
||||
|
||||
unsigned decompressChunk(unsigned readToSample, int16_t*& data) {
|
||||
unsigned startSamp = m_curSample;
|
||||
|
@ -180,7 +180,7 @@ struct SDSPStream : boo::IAudioVoiceCallback {
|
|||
return m_curSample - startSamp;
|
||||
}
|
||||
|
||||
size_t supplyAudio(boo::IAudioVoice&, size_t frames, int16_t* data) override {
|
||||
size_t supplyAudio(boo2::IAudioVoice&, size_t frames, int16_t* data) override {
|
||||
if (!x0_active) {
|
||||
memset(data, 0, frames * 2);
|
||||
return frames;
|
||||
|
@ -235,7 +235,7 @@ struct SDSPStream : boo::IAudioVoiceCallback {
|
|||
|
||||
return frames;
|
||||
}
|
||||
boo::ObjToken<boo::IAudioVoice> m_booVoice;
|
||||
boo2::ObjToken<boo2::IAudioVoice> m_booVoice;
|
||||
|
||||
void DoAllocateStream() {
|
||||
xd4_ringBuffer.reset(new u8[0x11DC0]);
|
||||
|
@ -307,8 +307,8 @@ struct SDSPStream : boo::IAudioVoiceCallback {
|
|||
return;
|
||||
}
|
||||
std::array<float, 8> coefs{};
|
||||
coefs[size_t(boo::AudioChannel::FrontLeft)] = m_leftgain * vol;
|
||||
coefs[size_t(boo::AudioChannel::FrontRight)] = m_rightgain * vol;
|
||||
coefs[size_t(boo2::AudioChannel::FrontLeft)] = m_leftgain * vol;
|
||||
coefs[size_t(boo2::AudioChannel::FrontRight)] = m_rightgain * vol;
|
||||
m_booVoice->setMonoChannelLevels(nullptr, coefs.data(), true);
|
||||
}
|
||||
|
||||
|
|
|
@ -488,7 +488,7 @@ void CAutoMapper::ProcessMapRotateInput(const CFinalInput& input, const CStateMa
|
|||
std::array<float, 4> dirs{};
|
||||
bool mouseHeld = false;
|
||||
if (const auto& kbm = input.GetKBM()) {
|
||||
if (kbm->m_mouseButtons[size_t(boo::EMouseButton::Primary)]) {
|
||||
if (kbm->m_mouseButtons[size_t(boo2::MouseButton::Primary)]) {
|
||||
mouseHeld = true;
|
||||
if (float(m_mouseDelta.x()) < 0.f)
|
||||
dirs[3] = -m_mouseDelta.x();
|
||||
|
@ -604,14 +604,14 @@ void CAutoMapper::ProcessMapZoomInput(const CFinalInput& input, const CStateMana
|
|||
if (const auto& kbm = input.GetKBM()) {
|
||||
m_mapScroll += kbm->m_accumScroll - m_lastAccumScroll;
|
||||
m_lastAccumScroll = kbm->m_accumScroll;
|
||||
if (m_mapScroll.delta[1] > 0.0) {
|
||||
if (m_mapScroll.y > 0.0) {
|
||||
in = true;
|
||||
zoomSpeed = std::max(1.f, float(m_mapScroll.delta[1]));
|
||||
m_mapScroll.delta[1] = std::max(0.0, m_mapScroll.delta[1] - (15.0 / 60.0));
|
||||
} else if (m_mapScroll.delta[1] < 0.0) {
|
||||
zoomSpeed = std::max(1.f, float(m_mapScroll.y));
|
||||
m_mapScroll.y = std::max(0.0, m_mapScroll.y - (15.0 / 60.0));
|
||||
} else if (m_mapScroll.y < 0.0) {
|
||||
out = true;
|
||||
zoomSpeed = std::max(1.f, float(-m_mapScroll.delta[1]));
|
||||
m_mapScroll.delta[1] = std::min(0.0, m_mapScroll.delta[1] + (15.0 / 60.0));
|
||||
zoomSpeed = std::max(1.f, float(-m_mapScroll.y));
|
||||
m_mapScroll.y = std::min(0.0, m_mapScroll.y + (15.0 / 60.0));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -648,7 +648,7 @@ void CAutoMapper::ProcessMapZoomInput(const CFinalInput& input, const CStateMana
|
|||
}
|
||||
|
||||
if (oldDist == xa8_renderStates[0].x18_camDist)
|
||||
m_mapScroll.delta[1] = 0.0;
|
||||
m_mapScroll.y = 0.0;
|
||||
SetShouldZoomingSoundBePlaying(oldDist != xa8_renderStates[0].x18_camDist);
|
||||
}
|
||||
|
||||
|
@ -660,8 +660,8 @@ void CAutoMapper::ProcessMapPanInput(const CFinalInput& input, const CStateManag
|
|||
|
||||
bool mouseHeld = false;
|
||||
if (const auto& kbm = input.GetKBM()) {
|
||||
if (kbm->m_mouseButtons[size_t(boo::EMouseButton::Middle)] ||
|
||||
kbm->m_mouseButtons[size_t(boo::EMouseButton::Secondary)]) {
|
||||
if (kbm->m_mouseButtons[size_t(boo2::MouseButton::Middle)] ||
|
||||
kbm->m_mouseButtons[size_t(boo2::MouseButton::Secondary)]) {
|
||||
mouseHeld = true;
|
||||
if (float(m_mouseDelta.x()) < 0.f)
|
||||
right += -m_mouseDelta.x();
|
||||
|
@ -787,10 +787,10 @@ void CAutoMapper::SetShouldRotatingSoundBePlaying(bool shouldBePlaying) {
|
|||
void CAutoMapper::ProcessMapScreenInput(const CFinalInput& input, CStateManager& mgr) {
|
||||
zeus::CMatrix3f camRot = xa8_renderStates[0].x8_camOrientation.toTransform().buildMatrix3f();
|
||||
if (x1bc_state == EAutoMapperState::MapScreen) {
|
||||
if ((input.PA() || input.PSpecialKey(boo::ESpecialKey::Enter)) && x328_ == 0 && HasCurrentMapUniverseWorld())
|
||||
if ((input.PA() || input.PKey('\n')) && x328_ == 0 && HasCurrentMapUniverseWorld())
|
||||
BeginMapperStateTransition(EAutoMapperState::MapScreenUniverse, mgr);
|
||||
} else if (x1bc_state == EAutoMapperState::MapScreenUniverse &&
|
||||
(input.PA() || input.PSpecialKey(boo::ESpecialKey::Enter))) {
|
||||
(input.PA() || input.PKey('\n'))) {
|
||||
const CMapUniverse::CMapWorldData& mapuWld = x8_mapu->GetMapWorldData(x9c_worldIdx);
|
||||
zeus::CVector3f pointLocal = mapuWld.GetWorldTransform().inverse() * xa8_renderStates[0].x20_areaPoint;
|
||||
if (mapuWld.GetWorldAssetId() != g_GameState->CurrentWorldAssetId()) {
|
||||
|
@ -805,7 +805,7 @@ void CAutoMapper::ProcessMapScreenInput(const CFinalInput& input, CStateManager&
|
|||
}
|
||||
|
||||
x2f4_aButtonPos = 0;
|
||||
if (input.PA() || input.PSpecialKey(boo::ESpecialKey::Enter))
|
||||
if (input.PA() || input.PKey('\n'))
|
||||
x2f4_aButtonPos = 1;
|
||||
|
||||
if (IsInPlayerControlState()) {
|
||||
|
@ -813,7 +813,7 @@ void CAutoMapper::ProcessMapScreenInput(const CFinalInput& input, CStateManager&
|
|||
x2f0_rTriggerPos = 0;
|
||||
|
||||
if (const auto& kbm = input.GetKBM()) {
|
||||
zeus::CVector2f mouseCoord = zeus::CVector2f(kbm->m_mouseCoord.norm[0], kbm->m_mouseCoord.norm[1]);
|
||||
zeus::CVector2f mouseCoord = zeus::CVector2f(kbm->m_mouseCoordNorm.x, kbm->m_mouseCoordNorm.y);
|
||||
if (!m_lastMouseCoord) {
|
||||
m_lastMouseCoord.emplace(mouseCoord);
|
||||
} else {
|
||||
|
@ -1081,7 +1081,7 @@ void CAutoMapper::ProcessControllerInput(const CFinalInput& input, CStateManager
|
|||
}
|
||||
}
|
||||
|
||||
if (input.PZ() || input.PKey('\t') || input.PB() || input.PSpecialKey(boo::ESpecialKey::Esc)) {
|
||||
if (input.PZ() || input.PKey('\t') || input.PB() || input.PSpecialKey(boo2::Keycode::ESC)) {
|
||||
if (x328_ == 0) {
|
||||
if (CanLeaveMapScreenInternal(mgr)) {
|
||||
LeaveMapScreen(mgr);
|
||||
|
@ -1486,7 +1486,7 @@ void CAutoMapper::Draw(const CStateManager& mgr, const zeus::CTransform& xf, flo
|
|||
colorAlpha *= mapAlpha;
|
||||
zeus::CColor color = zeus::skWhite;
|
||||
color.a() = colorAlpha;
|
||||
filter.drawVerts(color, verts.data());
|
||||
filter.drawVerts(color, verts);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -181,8 +181,8 @@ private:
|
|||
|
||||
std::optional<zeus::CVector2f> m_lastMouseCoord;
|
||||
zeus::CVector2f m_mouseDelta;
|
||||
boo::SScrollDelta m_lastAccumScroll;
|
||||
boo::SScrollDelta m_mapScroll;
|
||||
hsh::offset2dF m_lastAccumScroll;
|
||||
hsh::offset2dF m_mapScroll;
|
||||
|
||||
template <class T>
|
||||
static void SetResLockState(T& list, bool lock) {
|
||||
|
|
|
@ -107,43 +107,41 @@ void CMapArea::PostConstruct() {
|
|||
m_surfaces.emplace_back(x40_surfaceStart + j).PostConstruct(x44_buf.get(), index);
|
||||
}
|
||||
|
||||
CGraphics::CommitResources([this, &index](boo::IGraphicsDataFactory::Context& ctx) {
|
||||
m_vbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, m_verts.data(), 16, m_verts.size());
|
||||
m_ibo = ctx.newStaticBuffer(boo::BufferUse::Index, index.data(), 4, index.size());
|
||||
m_vbo = hsh::create_vertex_buffer<CMapSurfaceShader::Vert>(m_verts);
|
||||
m_ibo = hsh::create_index_buffer<u32>(index);
|
||||
|
||||
/* Only the map universe specifies Always; it draws a maximum of 1016 instances */
|
||||
size_t instCount = (xc_visibilityMode == EVisMode::Always) ? 1024 : 1;
|
||||
/* Only the map universe specifies Always; it draws a maximum of 1016 instances */
|
||||
size_t instCount = (xc_visibilityMode == EVisMode::Always) ? 1024 : 1;
|
||||
|
||||
for (u32 i = 0; i < x30_surfaceCount; ++i) {
|
||||
CMapAreaSurface& surf = m_surfaces[i];
|
||||
surf.m_instances.reserve(instCount);
|
||||
for (u32 inst = 0; inst < instCount; ++inst) {
|
||||
CMapAreaSurface::Instance& instance = surf.m_instances.emplace_back(ctx, m_vbo, m_ibo);
|
||||
for (u32 i = 0; i < x30_surfaceCount; ++i) {
|
||||
CMapAreaSurface& surf = m_surfaces[i];
|
||||
surf.m_instances.reserve(instCount);
|
||||
for (u32 inst = 0; inst < instCount; ++inst) {
|
||||
CMapAreaSurface::Instance& instance = surf.m_instances.emplace_back(m_vbo, m_ibo);
|
||||
|
||||
athena::io::MemoryReader r(surf.x1c_outlineOffset, INT_MAX);
|
||||
u32 outlineCount = r.readUint32Big();
|
||||
athena::io::MemoryReader r(surf.x1c_outlineOffset, INT_MAX);
|
||||
u32 outlineCount = r.readUint32Big();
|
||||
|
||||
std::vector<CLineRenderer>& linePrims = instance.m_linePrims;
|
||||
linePrims.reserve(outlineCount * 2);
|
||||
for (u32 j = 0; j < 2; ++j) {
|
||||
r.seek(4, athena::SeekOrigin::Begin);
|
||||
for (u32 k = 0; k < outlineCount; ++k) {
|
||||
const u32 count = r.readUint32Big();
|
||||
r.seek(count);
|
||||
r.seekAlign4();
|
||||
linePrims.emplace_back(ctx, CLineRenderer::EPrimitiveMode::LineStrip, count, nullptr, false, false, true);
|
||||
}
|
||||
std::vector<CLineRenderer>& linePrims = instance.m_linePrims;
|
||||
linePrims.reserve(outlineCount * 2);
|
||||
for (u32 j = 0; j < 2; ++j) {
|
||||
r.seek(4, athena::SeekOrigin::Begin);
|
||||
for (u32 k = 0; k < outlineCount; ++k) {
|
||||
const u32 count = r.readUint32Big();
|
||||
r.seek(count);
|
||||
r.seekAlign4();
|
||||
linePrims.emplace_back(CLineRenderer::EPrimitiveMode::LineStrip, count, hsh::texture2d{}, false,
|
||||
hsh::GEqual);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (u32 i = 0; i < x28_mappableObjCount; ++i) {
|
||||
CMappableObject& mapObj = m_mappableObjects[i];
|
||||
if (CMappableObject::IsDoorType(mapObj.GetType()))
|
||||
mapObj.CreateDoorSurface(ctx);
|
||||
}
|
||||
return true;
|
||||
} BooTrace);
|
||||
for (u32 i = 0; i < x28_mappableObjCount; ++i) {
|
||||
CMappableObject& mapObj = m_mappableObjects[i];
|
||||
if (CMappableObject::IsDoorType(mapObj.GetType()))
|
||||
mapObj.CreateDoorSurface();
|
||||
}
|
||||
}
|
||||
|
||||
bool CMapArea::GetIsVisibleToAutoMapper(bool worldVis, bool areaVis) const {
|
||||
|
@ -256,7 +254,7 @@ void CMapArea::CMapAreaSurface::PostConstruct(const u8* buf, std::vector<u32>& i
|
|||
m_primCount = index.size() - m_primStart;
|
||||
}
|
||||
|
||||
void CMapArea::CMapAreaSurface::Draw(const zeus::CVector3f* verts, const zeus::CColor& surfColor,
|
||||
void CMapArea::CMapAreaSurface::Draw(const CMapSurfaceShader::Vert* verts, const zeus::CColor& surfColor,
|
||||
const zeus::CColor& lineColor, float lineWidth, size_t instIdx) {
|
||||
if (instIdx >= m_instances.size()) {
|
||||
return;
|
||||
|
@ -288,7 +286,7 @@ void CMapArea::CMapAreaSurface::Draw(const zeus::CVector3f* verts, const zeus::C
|
|||
u32 count = r.readUint32Big();
|
||||
for (u32 v = 0; v < count; ++v) {
|
||||
u8 idx = r.readUByte();
|
||||
prim.AddVertex(verts[idx], color, width);
|
||||
prim.AddVertex(verts[idx].pos, color, width);
|
||||
}
|
||||
r.seekAlign4();
|
||||
prim.Render();
|
||||
|
|
|
@ -9,10 +9,8 @@
|
|||
#include "Runtime/Graphics/CLineRenderer.hpp"
|
||||
#include "Runtime/Graphics/Shaders/CMapSurfaceShader.hpp"
|
||||
|
||||
#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
||||
|
||||
#include <zeus/CAABox.hpp>
|
||||
#include <zeus/CVector3f.hpp>
|
||||
#include "zeus/CAABox.hpp"
|
||||
#include "zeus/CVector3f.hpp"
|
||||
|
||||
namespace urde {
|
||||
class IWorld;
|
||||
|
@ -29,9 +27,9 @@ public:
|
|||
struct Instance {
|
||||
CMapSurfaceShader m_surfacePrims;
|
||||
std::vector<CLineRenderer> m_linePrims;
|
||||
Instance(boo::IGraphicsDataFactory::Context& ctx, const boo::ObjToken<boo::IGraphicsBufferS>& vbo,
|
||||
const boo::ObjToken<boo::IGraphicsBufferS>& ibo)
|
||||
: m_surfacePrims(ctx, vbo, ibo) {}
|
||||
Instance(hsh::vertex_buffer<CMapSurfaceShader::Vert> vbo,
|
||||
hsh::index_buffer<u32> ibo)
|
||||
: m_surfacePrims(vbo, ibo) {}
|
||||
Instance(Instance&&) = default;
|
||||
Instance& operator=(Instance&&) = default;
|
||||
};
|
||||
|
@ -41,7 +39,7 @@ public:
|
|||
explicit CMapAreaSurface(const void* surfBuf);
|
||||
CMapAreaSurface(CMapAreaSurface&&) = default;
|
||||
void PostConstruct(const u8* buf, std::vector<u32>& index);
|
||||
void Draw(const zeus::CVector3f* verts, const zeus::CColor& surfColor, const zeus::CColor& lineColor,
|
||||
void Draw(const CMapSurfaceShader::Vert* verts, const zeus::CColor& surfColor, const zeus::CColor& lineColor,
|
||||
float lineWidth, size_t instIdx = 0);
|
||||
const zeus::CVector3f& GetNormal() const { return x0_normal; }
|
||||
const zeus::CVector3f& GetCenterPosition() const { return xc_centroid; }
|
||||
|
@ -61,12 +59,12 @@ private:
|
|||
u8* x38_moStart;
|
||||
std::vector<CMappableObject> m_mappableObjects;
|
||||
u8* x3c_vertexStart;
|
||||
std::vector<zeus::CVector3f> m_verts;
|
||||
std::vector<CMapSurfaceShader::Vert> m_verts;
|
||||
u8* x40_surfaceStart;
|
||||
std::vector<CMapAreaSurface> m_surfaces;
|
||||
std::unique_ptr<u8[]> x44_buf;
|
||||
boo::ObjToken<boo::IGraphicsBufferS> m_vbo;
|
||||
boo::ObjToken<boo::IGraphicsBufferS> m_ibo;
|
||||
hsh::owner<hsh::vertex_buffer<CMapSurfaceShader::Vert>> m_vbo;
|
||||
hsh::owner<hsh::index_buffer<u32>> m_ibo;
|
||||
|
||||
public:
|
||||
explicit CMapArea(CInputStream& in, u32 size);
|
||||
|
@ -82,7 +80,7 @@ public:
|
|||
u32 GetNumSurfaces() const { return m_surfaces.size(); }
|
||||
zeus::CTransform GetAreaPostTransform(const IWorld& world, TAreaId aid) const;
|
||||
static const zeus::CVector3f& GetAreaPostTranslate(const IWorld& world, TAreaId aid);
|
||||
const zeus::CVector3f* GetVertices() const { return m_verts.data(); }
|
||||
const CMapSurfaceShader::Vert* GetVertices() const { return m_verts.data(); }
|
||||
};
|
||||
|
||||
CFactoryFnReturn FMapAreaFactory(const SObjectTag& objTag, CInputStream& in, const CVParamTransfer&, CObjectReference*);
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include "Runtime/Graphics/CTexture.hpp"
|
||||
|
||||
namespace urde {
|
||||
std::array<zeus::CVector3f, 8> CMappableObject::skDoorVerts{};
|
||||
std::array<CMappableObject::Vert, 8> CMappableObject::skDoorVerts{};
|
||||
|
||||
constexpr std::array<u32, 24> DoorIndices{
|
||||
6, 4, 2, 0, 3, 1, 7, 5, 1, 0, 5, 4, 7, 6, 3, 2, 3, 2, 1, 0, 5, 4, 7, 6,
|
||||
|
@ -118,10 +118,10 @@ void CMappableObject::Draw(int curArea, const CMapWorldInfo& mwInfo, float alpha
|
|||
CLineRenderer& line = ds.m_outline;
|
||||
const u32* baseIdx = &DoorIndices[s * 4];
|
||||
line.Reset();
|
||||
line.AddVertex(skDoorVerts[baseIdx[0]], colors.second, 1.f);
|
||||
line.AddVertex(skDoorVerts[baseIdx[1]], colors.second, 1.f);
|
||||
line.AddVertex(skDoorVerts[baseIdx[3]], colors.second, 1.f);
|
||||
line.AddVertex(skDoorVerts[baseIdx[2]], colors.second, 1.f);
|
||||
line.AddVertex(skDoorVerts[baseIdx[0]].m_pos, colors.second, 1.f);
|
||||
line.AddVertex(skDoorVerts[baseIdx[1]].m_pos, colors.second, 1.f);
|
||||
line.AddVertex(skDoorVerts[baseIdx[3]].m_pos, colors.second, 1.f);
|
||||
line.AddVertex(skDoorVerts[baseIdx[2]].m_pos, colors.second, 1.f);
|
||||
line.Render();
|
||||
}
|
||||
} else {
|
||||
|
@ -176,7 +176,7 @@ void CMappableObject::Draw(int curArea, const CMapWorldInfo& mwInfo, float alpha
|
|||
{{2.6f, 0.f, 2.6f}, {1.f, 1.f}},
|
||||
{{2.6f, 0.f, -2.6f}, {1.f, 0.f}},
|
||||
}};
|
||||
m_texQuadFilter->drawVerts(iconColor, verts.data());
|
||||
m_texQuadFilter->drawVerts(iconColor, verts);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -188,10 +188,10 @@ void CMappableObject::DrawDoorSurface(int curArea, const CMapWorldInfo& mwInfo,
|
|||
CLineRenderer& line = ds.m_outline;
|
||||
const u32* baseIdx = &DoorIndices[surfIdx * 4];
|
||||
line.Reset();
|
||||
line.AddVertex(skDoorVerts[baseIdx[0]], colors.second, 1.f);
|
||||
line.AddVertex(skDoorVerts[baseIdx[1]], colors.second, 1.f);
|
||||
line.AddVertex(skDoorVerts[baseIdx[3]], colors.second, 1.f);
|
||||
line.AddVertex(skDoorVerts[baseIdx[2]], colors.second, 1.f);
|
||||
line.AddVertex(skDoorVerts[baseIdx[0]].m_pos, colors.second, 1.f);
|
||||
line.AddVertex(skDoorVerts[baseIdx[1]].m_pos, colors.second, 1.f);
|
||||
line.AddVertex(skDoorVerts[baseIdx[3]].m_pos, colors.second, 1.f);
|
||||
line.AddVertex(skDoorVerts[baseIdx[2]].m_pos, colors.second, 1.f);
|
||||
line.Render();
|
||||
}
|
||||
|
||||
|
@ -236,8 +236,8 @@ bool CMappableObject::IsVisibleToAutoMapper(bool worldVis, const CMapWorldInfo&
|
|||
}
|
||||
}
|
||||
|
||||
boo::ObjToken<boo::IGraphicsBufferS> CMappableObject::g_doorVbo;
|
||||
boo::ObjToken<boo::IGraphicsBufferS> CMappableObject::g_doorIbo;
|
||||
hsh::owner<hsh::vertex_buffer<CMappableObject::Vert>> CMappableObject::g_doorVbo;
|
||||
hsh::owner<hsh::index_buffer<u32>> CMappableObject::g_doorIbo;
|
||||
|
||||
void CMappableObject::ReadAutoMapperTweaks(const ITweakAutoMapper& tweaks) {
|
||||
const zeus::CVector3f& center = tweaks.GetDoorCenter();
|
||||
|
@ -254,11 +254,8 @@ void CMappableObject::ReadAutoMapperTweaks(const ITweakAutoMapper& tweaks) {
|
|||
doorVerts[6].assign(.2f * -centerF[2], centerF[1], 0.f);
|
||||
doorVerts[7].assign(.2f * -centerF[2], centerF[1], 2.f * centerF[0]);
|
||||
|
||||
CGraphics::CommitResources([](boo::IGraphicsDataFactory::Context& ctx) {
|
||||
g_doorVbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, skDoorVerts.data(), 16, skDoorVerts.size());
|
||||
g_doorIbo = ctx.newStaticBuffer(boo::BufferUse::Index, DoorIndices.data(), 4, DoorIndices.size());
|
||||
return true;
|
||||
} BooTrace);
|
||||
g_doorVbo = hsh::create_vertex_buffer(skDoorVerts);
|
||||
g_doorIbo = hsh::create_index_buffer(DoorIndices);
|
||||
}
|
||||
|
||||
void CMappableObject::Shutdown() {
|
||||
|
|
|
@ -18,10 +18,16 @@ class CMapWorldInfo;
|
|||
class CStateManager;
|
||||
|
||||
class CMappableObject {
|
||||
static boo::ObjToken<boo::IGraphicsBufferS> g_doorVbo;
|
||||
static boo::ObjToken<boo::IGraphicsBufferS> g_doorIbo;
|
||||
|
||||
public:
|
||||
struct Vert {
|
||||
hsh::float3 m_pos;
|
||||
void assign(float x, float y, float z) {
|
||||
m_pos = hsh::float3(x, y, z);
|
||||
}
|
||||
};
|
||||
static hsh::owner<hsh::vertex_buffer<Vert>> g_doorVbo;
|
||||
static hsh::owner<hsh::index_buffer<u32>> g_doorIbo;
|
||||
|
||||
enum class EMappableObjectType {
|
||||
BlueDoor = 0,
|
||||
ShieldDoor = 1,
|
||||
|
@ -53,7 +59,7 @@ public:
|
|||
enum class EVisMode { Always, MapStationOrVisit, Visit, Never, MapStationOrVisit2 };
|
||||
|
||||
private:
|
||||
static std::array<zeus::CVector3f, 8> skDoorVerts;
|
||||
static std::array<CMappableObject::Vert, 8> skDoorVerts;
|
||||
|
||||
EMappableObjectType x0_type;
|
||||
EVisMode x4_visibilityMode;
|
||||
|
@ -64,9 +70,9 @@ private:
|
|||
struct DoorSurface {
|
||||
CMapSurfaceShader m_surface;
|
||||
CLineRenderer m_outline;
|
||||
explicit DoorSurface(boo::IGraphicsDataFactory::Context& ctx)
|
||||
: m_surface(ctx, g_doorVbo, g_doorIbo)
|
||||
, m_outline(ctx, CLineRenderer::EPrimitiveMode::LineLoop, 5, nullptr, false, false, true) {}
|
||||
explicit DoorSurface()
|
||||
: m_surface(g_doorVbo.get(), g_doorIbo.get())
|
||||
, m_outline(CLineRenderer::EPrimitiveMode::LineLoop, 5, hsh::texture2d{}, false, hsh::GEqual) {}
|
||||
};
|
||||
std::optional<DoorSurface> m_doorSurface;
|
||||
std::optional<CTexturedQuadFilter> m_texQuadFilter;
|
||||
|
@ -87,7 +93,7 @@ public:
|
|||
bool IsDoorConnectedToVisitedArea(const CStateManager&) const;
|
||||
bool IsVisibleToAutoMapper(bool worldVis, const CMapWorldInfo& mwInfo) const;
|
||||
bool GetIsSeen() const;
|
||||
void CreateDoorSurface(boo::IGraphicsDataFactory::Context& ctx) { m_doorSurface.emplace(ctx); }
|
||||
void CreateDoorSurface() { m_doorSurface.emplace(); }
|
||||
|
||||
static void ReadAutoMapperTweaks(const ITweakAutoMapper&);
|
||||
static bool GetTweakIsMapVisibilityCheat();
|
||||
|
|
|
@ -388,7 +388,7 @@ void CGameOptions::TryRestoreDefaults(const CFinalInput& input, int category, in
|
|||
if (options.second[option].option != EGameOption::RestoreDefaults)
|
||||
return;
|
||||
|
||||
if (!forceRestore && !input.PA() && !input.PSpecialKey(boo::ESpecialKey::Enter))
|
||||
if (!forceRestore && !input.PA() && !input.PKey('\n'))
|
||||
return;
|
||||
|
||||
if (frontend) {
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
#include "Runtime/CGameOptionsTouchBar.hpp"
|
||||
|
||||
namespace urde {
|
||||
|
||||
CGameOptionsTouchBar::EAction CGameOptionsTouchBar::PopAction() { return EAction::None; }
|
||||
void CGameOptionsTouchBar::GetSelection(int& left, int& right, int& value) { left = -1, right = -1, value = -1; }
|
||||
void CGameOptionsTouchBar::SetSelection(int left, int right, int value) {}
|
||||
|
||||
#ifndef __APPLE__
|
||||
std::unique_ptr<CGameOptionsTouchBar> NewGameOptionsTouchBar() { return std::make_unique<CGameOptionsTouchBar>(); }
|
||||
#endif
|
||||
|
||||
} // namespace urde
|
|
@ -1,20 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
namespace urde {
|
||||
|
||||
class CGameOptionsTouchBar {
|
||||
public:
|
||||
enum class EAction { None, Back, Advance, ValueChange };
|
||||
|
||||
virtual ~CGameOptionsTouchBar() = default;
|
||||
virtual EAction PopAction();
|
||||
virtual void GetSelection(int& left, int& right, int& value);
|
||||
virtual void SetSelection(int left, int right, int value);
|
||||
};
|
||||
|
||||
std::unique_ptr<CGameOptionsTouchBar> NewGameOptionsTouchBar();
|
||||
|
||||
} // namespace urde
|
|
@ -1,307 +0,0 @@
|
|||
#include <AppKit/AppKit.h>
|
||||
#include "CGameOptionsTouchBar.hpp"
|
||||
#include "CGameOptions.hpp"
|
||||
#include "GameGlobalObjects.hpp"
|
||||
#include "MP1/MP1.hpp"
|
||||
#include "GuiSys/CStringTable.hpp"
|
||||
|
||||
#if !__has_feature(objc_arc)
|
||||
#error ARC Required
|
||||
#endif
|
||||
|
||||
static NSColor* BlueConfirm()
|
||||
{
|
||||
return [NSColor colorWithSRGBRed:0/255.f green:130/255.f blue:215/255.f alpha:1.f];
|
||||
}
|
||||
|
||||
@interface GameOptionsTouchBar : NSObject <NSTouchBarDelegate>
|
||||
{
|
||||
@public
|
||||
urde::CStringTable* _pauseScreenStrg;
|
||||
urde::CGameOptionsTouchBar::EAction _action;
|
||||
std::pair<int, int> _selection;
|
||||
int _value, _pendingValue;
|
||||
}
|
||||
-(IBAction)onBack:(id)sender;
|
||||
-(IBAction)onSlide:(id)sender;
|
||||
-(IBAction)onSet0:(id)sender;
|
||||
-(IBAction)onSet1:(id)sender;
|
||||
-(IBAction)onSet2:(id)sender;
|
||||
-(IBAction)onLeft:(id)sender;
|
||||
-(IBAction)onRight:(id)sender;
|
||||
@end
|
||||
|
||||
@implementation GameOptionsTouchBar
|
||||
- (NSTouchBar*)makeTouchBar
|
||||
{
|
||||
NSTouchBar* touchBar = [NSTouchBar new];
|
||||
touchBar.delegate = self;
|
||||
id items = @[@"optionsGroup"];
|
||||
touchBar.customizationRequiredItemIdentifiers = items;
|
||||
touchBar.defaultItemIdentifiers = items;
|
||||
touchBar.principalItemIdentifier = @"optionsGroup";
|
||||
return touchBar;
|
||||
}
|
||||
-(NSTouchBarItem*)touchBar:(NSTouchBar*)touchBar
|
||||
makeItemForIdentifier:(NSTouchBarItemIdentifier)identifier
|
||||
{
|
||||
if ([identifier isEqualToString:@"optionsGroup"])
|
||||
{
|
||||
NSGroupTouchBarItem* item = [[NSGroupTouchBarItem alloc] initWithIdentifier:identifier];
|
||||
NSTouchBar* touchBar = [NSTouchBar new];
|
||||
touchBar.delegate = self;
|
||||
id items;
|
||||
if (_selection.first == -1)
|
||||
{
|
||||
items = [NSMutableArray arrayWithCapacity:5];
|
||||
[items addObject:@"back"];
|
||||
for (int i=0 ; i<4 ; ++i)
|
||||
[items addObject:[NSString stringWithFormat:@"left/%d", i]];
|
||||
}
|
||||
else if (_selection.second == -1)
|
||||
{
|
||||
const std::pair<int, const urde::SGameOption*>& opt = urde::GameOptionsRegistry[_selection.first];
|
||||
items = [NSMutableArray arrayWithCapacity:opt.first+1];
|
||||
[items addObject:@"back"];
|
||||
for (int i=0 ; i<opt.first ; ++i)
|
||||
[items addObject:[NSString stringWithFormat:@"right/%d", i]];
|
||||
}
|
||||
else
|
||||
{
|
||||
const std::pair<int, const urde::SGameOption*>& opt = urde::GameOptionsRegistry[_selection.first];
|
||||
const urde::SGameOption& subopt = opt.second[_selection.second];
|
||||
if (subopt.type == urde::EOptionType::Float)
|
||||
items = @[@"back", @"value"];
|
||||
else if (subopt.type == urde::EOptionType::DoubleEnum)
|
||||
items = @[@"back", @"label", @"double0", @"double1"];
|
||||
else if (subopt.type == urde::EOptionType::TripleEnum)
|
||||
items = @[@"back", @"label", @"triple0", @"triple1", @"triple2"];
|
||||
}
|
||||
touchBar.customizationRequiredItemIdentifiers = items;
|
||||
touchBar.defaultItemIdentifiers = items;
|
||||
item.groupTouchBar = touchBar;
|
||||
return item;
|
||||
}
|
||||
else if ([identifier isEqualToString:@"back"])
|
||||
{
|
||||
NSCustomTouchBarItem* item = [[NSCustomTouchBarItem alloc] initWithIdentifier:identifier];
|
||||
NSButton* button = [NSButton buttonWithImage:[NSImage imageNamed:NSImageNameTouchBarGoBackTemplate]
|
||||
target:self action:@selector(onBack:)];
|
||||
item.view = button;
|
||||
return item;
|
||||
}
|
||||
else if ([identifier isEqualToString:@"label"])
|
||||
{
|
||||
const std::pair<int, const urde::SGameOption*>& opt = urde::GameOptionsRegistry[_selection.first];
|
||||
const urde::SGameOption& subopt = opt.second[_selection.second];
|
||||
|
||||
const char16_t* cStr = _pauseScreenStrg->GetString(subopt.stringId);
|
||||
NSString* str = [NSString stringWithUTF8String:hecl::Char16ToUTF8(cStr).c_str()];
|
||||
|
||||
NSCustomTouchBarItem* item = [[NSCustomTouchBarItem alloc] initWithIdentifier:identifier];
|
||||
NSTextField* label = [NSTextField labelWithString:[str stringByAppendingString:@":"]];
|
||||
item.view = label;
|
||||
return item;
|
||||
}
|
||||
else if ([identifier isEqualToString:@"value"])
|
||||
{
|
||||
const std::pair<int, const urde::SGameOption*>& opt = urde::GameOptionsRegistry[_selection.first];
|
||||
const urde::SGameOption& subopt = opt.second[_selection.second];
|
||||
|
||||
const char16_t* cStr = _pauseScreenStrg->GetString(subopt.stringId);
|
||||
NSString* str = [NSString stringWithUTF8String:hecl::Char16ToUTF8(cStr).c_str()];
|
||||
|
||||
NSSliderTouchBarItem* item = [[NSSliderTouchBarItem alloc] initWithIdentifier:identifier];
|
||||
NSSlider* slider = [NSSlider sliderWithValue:_value minValue:subopt.minVal maxValue:subopt.maxVal
|
||||
target:nil action:nil];
|
||||
item.target = self;
|
||||
item.action = @selector(onSlide:);
|
||||
item.slider = slider;
|
||||
item.label = str;
|
||||
return item;
|
||||
}
|
||||
else if ([identifier isEqualToString:@"double0"])
|
||||
{
|
||||
const char16_t* cStr = _pauseScreenStrg->GetString(95); // Off
|
||||
NSString* str = [NSString stringWithUTF8String:hecl::Char16ToUTF8(cStr).c_str()];
|
||||
|
||||
NSCustomTouchBarItem* item = [[NSCustomTouchBarItem alloc] initWithIdentifier:identifier];
|
||||
NSButton* button = [NSButton buttonWithTitle:str target:self action:@selector(onSet0:)];
|
||||
if (_value == 0)
|
||||
button.bezelColor = BlueConfirm();
|
||||
item.view = button;
|
||||
return item;
|
||||
}
|
||||
else if ([identifier isEqualToString:@"double1"])
|
||||
{
|
||||
const char16_t* cStr = _pauseScreenStrg->GetString(94); // On
|
||||
NSString* str = [NSString stringWithUTF8String:hecl::Char16ToUTF8(cStr).c_str()];
|
||||
|
||||
NSCustomTouchBarItem* item = [[NSCustomTouchBarItem alloc] initWithIdentifier:identifier];
|
||||
NSButton* button = [NSButton buttonWithTitle:str target:self action:@selector(onSet1:)];
|
||||
if (_value == 1)
|
||||
button.bezelColor = BlueConfirm();
|
||||
item.view = button;
|
||||
return item;
|
||||
}
|
||||
else if ([identifier isEqualToString:@"triple0"])
|
||||
{
|
||||
const char16_t* cStr = _pauseScreenStrg->GetString(96); // Mono
|
||||
NSString* str = [NSString stringWithUTF8String:hecl::Char16ToUTF8(cStr).c_str()];
|
||||
|
||||
NSCustomTouchBarItem* item = [[NSCustomTouchBarItem alloc] initWithIdentifier:identifier];
|
||||
NSButton* button = [NSButton buttonWithTitle:str target:self action:@selector(onSet0:)];
|
||||
if (_value == 0)
|
||||
button.bezelColor = BlueConfirm();
|
||||
item.view = button;
|
||||
return item;
|
||||
}
|
||||
else if ([identifier isEqualToString:@"triple1"])
|
||||
{
|
||||
const char16_t* cStr = _pauseScreenStrg->GetString(97); // Stereo
|
||||
NSString* str = [NSString stringWithUTF8String:hecl::Char16ToUTF8(cStr).c_str()];
|
||||
|
||||
NSCustomTouchBarItem* item = [[NSCustomTouchBarItem alloc] initWithIdentifier:identifier];
|
||||
NSButton* button = [NSButton buttonWithTitle:str target:self action:@selector(onSet1:)];
|
||||
if (_value == 1)
|
||||
button.bezelColor = BlueConfirm();
|
||||
item.view = button;
|
||||
return item;
|
||||
}
|
||||
else if ([identifier isEqualToString:@"triple2"])
|
||||
{
|
||||
const char16_t* cStr = _pauseScreenStrg->GetString(98); // Dolby
|
||||
NSString* str = [NSString stringWithUTF8String:hecl::Char16ToUTF8(cStr).c_str()];
|
||||
|
||||
NSCustomTouchBarItem* item = [[NSCustomTouchBarItem alloc] initWithIdentifier:identifier];
|
||||
NSButton* button = [NSButton buttonWithTitle:str target:self action:@selector(onSet2:)];
|
||||
if (_value == 2)
|
||||
button.bezelColor = BlueConfirm();
|
||||
item.view = button;
|
||||
return item;
|
||||
}
|
||||
else
|
||||
{
|
||||
NSArray<NSString*>* pc = [identifier pathComponents];
|
||||
if ([pc count] == 2)
|
||||
{
|
||||
NSString* first = [pc objectAtIndex:0];
|
||||
if ([first isEqualToString:@"left"])
|
||||
{
|
||||
auto idx = strtoul([[pc objectAtIndex:1] UTF8String], nullptr, 10);
|
||||
const char16_t* cStr = _pauseScreenStrg->GetString(16+idx);
|
||||
NSString* str = [NSString stringWithUTF8String:hecl::Char16ToUTF8(cStr).c_str()];
|
||||
|
||||
NSCustomTouchBarItem* item = [[NSCustomTouchBarItem alloc] initWithIdentifier:identifier];
|
||||
NSButton* button = [NSButton buttonWithTitle:str target:self action:@selector(onLeft:)];
|
||||
button.tag = idx;
|
||||
item.view = button;
|
||||
return item;
|
||||
}
|
||||
else if ([first isEqualToString:@"right"])
|
||||
{
|
||||
const std::pair<int, const urde::SGameOption*>& opt = urde::GameOptionsRegistry[_selection.first];
|
||||
auto idx = strtoul([[pc objectAtIndex:1] UTF8String], nullptr, 10);
|
||||
const urde::SGameOption& subopt = opt.second[idx];
|
||||
const char16_t* cStr = _pauseScreenStrg->GetString(subopt.stringId);
|
||||
NSString* str = [NSString stringWithUTF8String:hecl::Char16ToUTF8(cStr).c_str()];
|
||||
|
||||
NSCustomTouchBarItem* item = [[NSCustomTouchBarItem alloc] initWithIdentifier:identifier];
|
||||
NSButton* button = [NSButton buttonWithTitle:str target:self action:@selector(onRight:)];
|
||||
button.tag = idx;
|
||||
item.view = button;
|
||||
return item;
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
-(IBAction)onBack:(id)sender
|
||||
{
|
||||
_action = urde::CGameOptionsTouchBar::EAction::Back;
|
||||
}
|
||||
-(IBAction)onSlide:(id)sender
|
||||
{
|
||||
_pendingValue = [((NSSliderTouchBarItem*)sender).slider intValue];
|
||||
_action = urde::CGameOptionsTouchBar::EAction::ValueChange;
|
||||
}
|
||||
-(IBAction)onSet0:(id)sender
|
||||
{
|
||||
_pendingValue = 0;
|
||||
_action = urde::CGameOptionsTouchBar::EAction::ValueChange;
|
||||
}
|
||||
-(IBAction)onSet1:(id)sender
|
||||
{
|
||||
_pendingValue = 1;
|
||||
_action = urde::CGameOptionsTouchBar::EAction::ValueChange;
|
||||
}
|
||||
-(IBAction)onSet2:(id)sender
|
||||
{
|
||||
_pendingValue = 2;
|
||||
_action = urde::CGameOptionsTouchBar::EAction::ValueChange;
|
||||
}
|
||||
-(IBAction)onLeft:(id)sender
|
||||
{
|
||||
_selection.first = ((NSButton*)sender).tag;
|
||||
_action = urde::CGameOptionsTouchBar::EAction::Advance;
|
||||
}
|
||||
-(IBAction)onRight:(id)sender
|
||||
{
|
||||
_selection.second = ((NSButton*)sender).tag;
|
||||
_action = urde::CGameOptionsTouchBar::EAction::Advance;
|
||||
}
|
||||
@end
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
class CGameOptionsTouchBarMac : public CGameOptionsTouchBar
|
||||
{
|
||||
TLockedToken<CStringTable> m_pauseScreen;
|
||||
GameOptionsTouchBar* m_touchBar;
|
||||
bool m_initialized = false;
|
||||
public:
|
||||
CGameOptionsTouchBarMac()
|
||||
{
|
||||
m_pauseScreen = g_SimplePool->GetObj("STRG_PauseScreen");
|
||||
m_touchBar = [GameOptionsTouchBar new];
|
||||
m_touchBar->_pauseScreenStrg = m_pauseScreen.GetObj();
|
||||
m_touchBar->_selection = std::make_pair(-1, -1);
|
||||
m_touchBar->_value = -1;
|
||||
}
|
||||
EAction PopAction()
|
||||
{
|
||||
if (m_touchBar->_action != EAction::None)
|
||||
{
|
||||
EAction action = m_touchBar->_action;
|
||||
m_touchBar->_action = EAction::None;
|
||||
return action;
|
||||
}
|
||||
return EAction::None;
|
||||
}
|
||||
void GetSelection(int& left, int& right, int& value)
|
||||
{
|
||||
left = m_touchBar->_selection.first;
|
||||
right = m_touchBar->_selection.second;
|
||||
value = m_touchBar->_pendingValue;
|
||||
}
|
||||
void SetSelection(int left, int right, int value)
|
||||
{
|
||||
if (m_initialized &&
|
||||
left == m_touchBar->_selection.first &&
|
||||
right == m_touchBar->_selection.second &&
|
||||
value == m_touchBar->_value)
|
||||
return;
|
||||
m_initialized = true;
|
||||
m_touchBar->_selection = std::make_pair(left, right);
|
||||
m_touchBar->_value = value;
|
||||
g_Main->GetMainWindow()->setTouchBarProvider((__bridge_retained void*)m_touchBar);
|
||||
}
|
||||
};
|
||||
|
||||
std::unique_ptr<CGameOptionsTouchBar> NewGameOptionsTouchBar()
|
||||
{
|
||||
return std::make_unique<CGameOptionsTouchBarMac>();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
#include "CMain.hpp"
|
||||
|
||||
#include "boo2/boo2.hpp"
|
||||
#include "logvisor/logvisor.hpp"
|
||||
|
||||
namespace urde {
|
||||
|
||||
template <class App, class Win>
|
||||
class Delegate : public boo2::DelegateBase<App, Win> {
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) noexcept {
|
||||
logvisor::RegisterConsoleLogger();
|
||||
return boo2::Application<urde::Delegate>::exec(argc, argv, "urde"sv);
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
#pragma once
|
||||
|
||||
namespace urde {
|
||||
|
||||
}
|
|
@ -10,6 +10,18 @@ macro(runtime_add_list rel_path a_list)
|
|||
set(${a_list} "${tmp_list}" PARENT_SCOPE)
|
||||
endmacro(runtime_add_list)
|
||||
|
||||
macro(runtime_add_hsh rel_path)
|
||||
set(tmp_list ${HSH_SOURCES})
|
||||
foreach(path ${ARGN})
|
||||
if(IS_ABSOLUTE ${path})
|
||||
list(APPEND tmp_list "${path}")
|
||||
else()
|
||||
list(APPEND tmp_list "${rel_path}/${path}")
|
||||
endif()
|
||||
endforeach(path)
|
||||
set(HSH_SOURCES ${tmp_list} PARENT_SCOPE)
|
||||
endmacro(runtime_add_hsh)
|
||||
|
||||
add_subdirectory(Audio)
|
||||
add_subdirectory(Character)
|
||||
add_subdirectory(Graphics)
|
||||
|
@ -22,6 +34,8 @@ add_subdirectory(GuiSys)
|
|||
add_subdirectory(Input)
|
||||
add_subdirectory(Particle)
|
||||
|
||||
hsh_sources(${HSH_SOURCES})
|
||||
|
||||
if(WIN32)
|
||||
list(APPEND PLAT_SRCS CMemoryCardSysWin.cpp)
|
||||
elseif(APPLE)
|
||||
|
@ -39,15 +53,6 @@ add_subdirectory(MP1)
|
|||
add_subdirectory(MP2)
|
||||
add_subdirectory(MP3)
|
||||
|
||||
if(APPLE)
|
||||
set_source_files_properties(MP1/CFrontEndUITouchBarMac.mm
|
||||
MP1/CSaveGameScreenTouchBarMac.mm
|
||||
CGameOptionsTouchBarMac.mm
|
||||
PROPERTIES COMPILE_FLAGS -fobjc-arc)
|
||||
bintoc(startButton.cpp Resources/startButton@2x.png START_BUTTON_2X)
|
||||
list(APPEND PLAT_SRCS startButton.cpp CGameOptionsTouchBarMac.mm)
|
||||
endif()
|
||||
|
||||
set(RUNTIME_SOURCES_A
|
||||
RetroTypes.hpp RetroTypes.cpp
|
||||
${CLIENT_SOURCES}
|
||||
|
@ -88,7 +93,6 @@ set(RUNTIME_SOURCES_B
|
|||
IObjectStore.hpp
|
||||
CSimplePool.hpp CSimplePool.cpp
|
||||
CGameOptions.hpp CGameOptions.cpp
|
||||
CGameOptionsTouchBar.hpp CGameOptionsTouchBar.cpp
|
||||
CStaticInterference.hpp CStaticInterference.cpp
|
||||
CCRC32.hpp CCRC32.cpp
|
||||
IFactory.hpp
|
||||
|
@ -132,7 +136,7 @@ endif()
|
|||
endfunction()
|
||||
|
||||
set(RUNTIME_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
|
||||
set(RUNTIME_LIBRARIES ${HECL_APPLICATION_REPS_TARGETS_LIST} RetroDataSpec NESEmulator
|
||||
set(RUNTIME_LIBRARIES RetroDataSpec NESEmulator
|
||||
libjpeg-turbo jbus kabufuda discord-rpc logvisor)
|
||||
|
||||
if(MSVC)
|
||||
|
@ -143,8 +147,14 @@ if(MSVC)
|
|||
target_include_directories(RuntimeCommonB PUBLIC ${RUNTIME_INCLUDES})
|
||||
target_link_libraries(RuntimeCommonB PUBLIC ${RUNTIME_LIBRARIES})
|
||||
target_link_libraries(RuntimeCommon PUBLIC RuntimeCommonB)
|
||||
target_hsh(RuntimeCommon)
|
||||
target_hsh(RuntimeCommonB)
|
||||
else()
|
||||
add_runtime_common_library(RuntimeCommon ${RUNTIME_SOURCES_A} ${RUNTIME_SOURCES_B})
|
||||
target_include_directories(RuntimeCommon PUBLIC ${RUNTIME_INCLUDES})
|
||||
target_link_libraries(RuntimeCommon PUBLIC ${RUNTIME_LIBRARIES})
|
||||
target_hsh(RuntimeCommon)
|
||||
endif()
|
||||
|
||||
add_executable(urde CMain.hpp CMain.cpp)
|
||||
target_link_libraries(urde PUBLIC RuntimeCommon)
|
||||
|
|
|
@ -639,7 +639,7 @@ void CStateManager::ResetViewAfterDraw(const SViewport& backupViewport,
|
|||
cam->GetFarClipDistance());
|
||||
}
|
||||
|
||||
void CStateManager::DrawWorld() {
|
||||
void CStateManager::'DrawWorld() {
|
||||
SCOPED_GRAPHICS_DEBUG_GROUP("CStateManager::DrawWorld", zeus::skBlue);
|
||||
const CTimeProvider timeProvider(xf14_curTimeMod900);
|
||||
const SViewport backupViewport = g_Viewport;
|
||||
|
|
|
@ -5,10 +5,12 @@
|
|||
|
||||
#include "Runtime/CToken.hpp"
|
||||
#include "Runtime/RetroTypes.hpp"
|
||||
#include "Runtime/Graphics/CGraphics.hpp"
|
||||
#include "Runtime/Graphics/Shaders/CCameraBlurFilter.hpp"
|
||||
#include "Runtime/Graphics/Shaders/CXRayBlurFilter.hpp"
|
||||
|
||||
#include <zeus/CColor.hpp>
|
||||
#include "hsh/hsh.h"
|
||||
#include "zeus/CColor.hpp"
|
||||
|
||||
namespace urde {
|
||||
class CTexture;
|
||||
|
@ -26,6 +28,33 @@ enum class EFilterType {
|
|||
InvDstMultiply
|
||||
};
|
||||
|
||||
template <EFilterType FT, hsh::Compare ZComp = hsh::Always>
|
||||
struct FilterPipeline : hsh::pipeline::pipeline<hsh::pipeline::color_attachment<>> {};
|
||||
|
||||
template <hsh::Compare ZComp>
|
||||
struct FilterPipeline<EFilterType::Passthru, ZComp>
|
||||
: hsh::pipeline::pipeline<hsh::pipeline::color_attachment<>, hsh::pipeline::depth_compare<ZComp>> {};
|
||||
|
||||
template <hsh::Compare ZComp>
|
||||
struct FilterPipeline<EFilterType::Multiply, ZComp>
|
||||
: hsh::pipeline::pipeline<MultiplyAttachment<false>, hsh::pipeline::depth_compare<ZComp>> {};
|
||||
|
||||
template <hsh::Compare ZComp>
|
||||
struct FilterPipeline<EFilterType::Add, ZComp>
|
||||
: hsh::pipeline::pipeline<AdditiveAttachment<false>, hsh::pipeline::depth_compare<ZComp>> {};
|
||||
|
||||
template <hsh::Compare ZComp>
|
||||
struct FilterPipeline<EFilterType::Blend, ZComp>
|
||||
: hsh::pipeline::pipeline<BlendAttachment<false>, hsh::pipeline::depth_compare<ZComp>> {};
|
||||
|
||||
template <hsh::Compare ZComp>
|
||||
struct FilterPipeline<EFilterType::NoColor, ZComp>
|
||||
: hsh::pipeline::pipeline<NoColorAttachmentExt<AlphaMode::AlphaReplace>, hsh::pipeline::depth_compare<ZComp>> {};
|
||||
|
||||
template <hsh::Compare ZComp>
|
||||
struct FilterPipeline<EFilterType::InvDstMultiply, ZComp>
|
||||
: hsh::pipeline::pipeline<InvDstMultiplyAttachmentExt<AlphaMode::AlphaReplace>, hsh::pipeline::depth_compare<ZComp>> {};
|
||||
|
||||
enum class EFilterShape {
|
||||
Fullscreen,
|
||||
FullscreenHalvesLeftRight,
|
||||
|
|
|
@ -6,8 +6,7 @@
|
|||
#include "Runtime/RetroTypes.hpp"
|
||||
#include "Runtime/Character/CSkinBank.hpp"
|
||||
|
||||
#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
||||
#include <zeus/CVector3f.hpp>
|
||||
#include "zeus/CVector3f.hpp"
|
||||
|
||||
namespace urde {
|
||||
class CPoseAsTransforms;
|
||||
|
|
|
@ -15,12 +15,11 @@
|
|||
#include <algorithm>
|
||||
#include <array>
|
||||
|
||||
#include <boo/System.hpp>
|
||||
#include <logvisor/logvisor.hpp>
|
||||
#include <zeus/CColor.hpp>
|
||||
#include <zeus/CUnitVector.hpp>
|
||||
#include <zeus/CVector3d.hpp>
|
||||
#include <zeus/CVector4f.hpp>
|
||||
#include "logvisor/logvisor.hpp"
|
||||
#include "zeus/CColor.hpp"
|
||||
#include "zeus/CUnitVector.hpp"
|
||||
#include "zeus/CVector3d.hpp"
|
||||
#include "zeus/CVector4f.hpp"
|
||||
|
||||
#define FOGVOL_RAMP_RES 256
|
||||
#define FOGVOL_FAR 750.0
|
||||
|
|
|
@ -107,24 +107,29 @@ class CBooRenderer final : public IRenderer {
|
|||
// boo::ITextureS* xe4_blackTex = nullptr;
|
||||
bool xee_24_ : 1;
|
||||
|
||||
boo::ObjToken<boo::ITexture> m_clearTexture;
|
||||
boo::ObjToken<boo::ITexture> m_blackTexture;
|
||||
boo::ObjToken<boo::ITexture> m_whiteTexture;
|
||||
std::unordered_map<zeus::CColor, boo::ObjToken<boo::ITexture>> m_colorTextures;
|
||||
hsh::owner<hsh::texture2d> m_clearTexture;
|
||||
hsh::owner<hsh::texture2d> m_blackTexture;
|
||||
hsh::owner<hsh::texture2d> m_whiteTexture;
|
||||
std::unordered_map<zeus::CColor, hsh::owner<hsh::texture2d>> m_colorTextures;
|
||||
|
||||
boo::ObjToken<boo::ITextureR> x14c_reflectionTex;
|
||||
hsh::owner<hsh::render_texture2d> x14c_reflectionTex;
|
||||
// boo::ITextureS* x150_mirrorRamp = nullptr;
|
||||
boo::ObjToken<boo::ITextureS> x1b8_fogVolumeRamp;
|
||||
boo::ObjToken<boo::ITextureS> x220_sphereRamp;
|
||||
hsh::owner<hsh::texture2d> x1b8_fogVolumeRamp;
|
||||
hsh::owner<hsh::texture2d> x220_sphereRamp;
|
||||
TLockedToken<CTexture> m_thermoPaletteTex;
|
||||
boo::ObjToken<boo::ITexture> x288_thermoPalette;
|
||||
hsh::owner<hsh::texture2d> x288_thermoPalette;
|
||||
TLockedToken<CTexture> m_ballFadeTex;
|
||||
boo::ObjToken<boo::ITexture> m_ballFade;
|
||||
boo::ObjToken<boo::ITextureR> m_ballShadowId;
|
||||
boo::ObjToken<boo::IGraphicsBufferS> m_scanLinesEvenVBO;
|
||||
boo::ObjToken<boo::IGraphicsBufferS> m_scanLinesOddVBO;
|
||||
int m_ballShadowIdW = 64;
|
||||
int m_ballShadowIdH = 64;
|
||||
hsh::owner<hsh::texture2d> m_ballFade;
|
||||
hsh::owner<hsh::render_texture2d> m_ballShadowId;
|
||||
|
||||
struct ScanlinesVert {
|
||||
hsh::float3 pos;
|
||||
};
|
||||
hsh::owner<hsh::vertex_buffer<ScanlinesVert>> m_scanLinesEvenVBO;
|
||||
hsh::owner<hsh::vertex_buffer<ScanlinesVert>> m_scanLinesOddVBO;
|
||||
|
||||
uint32_t m_ballShadowIdW = 64;
|
||||
uint32_t m_ballShadowIdH = 64;
|
||||
|
||||
CRandom16 x2a8_thermalRand;
|
||||
std::list<CFogVolumeListItem> x2ac_fogVolumes;
|
||||
|
@ -162,9 +167,9 @@ class CBooRenderer final : public IRenderer {
|
|||
bool x318_31_persistRGBA6 : 1;
|
||||
bool m_thermalHotPass : 1;
|
||||
|
||||
void GenerateFogVolumeRampTex(boo::IGraphicsDataFactory::Context& ctx);
|
||||
void GenerateSphereRampTex(boo::IGraphicsDataFactory::Context& ctx);
|
||||
void GenerateScanLinesVBO(boo::IGraphicsDataFactory::Context& ctx);
|
||||
void GenerateFogVolumeRampTex();
|
||||
void GenerateSphereRampTex();
|
||||
void GenerateScanLinesVBO();
|
||||
void LoadThermoPalette();
|
||||
void LoadBallFade();
|
||||
|
||||
|
@ -270,27 +275,23 @@ public:
|
|||
void ReallyRenderFogVolume(const zeus::CColor& color, const zeus::CAABox& aabb, const CModel* model,
|
||||
const CSkinnedModel* sModel);
|
||||
|
||||
const boo::ObjToken<boo::ITexture>& GetThermoPalette() const { return x288_thermoPalette; }
|
||||
const boo::ObjToken<boo::ITextureS>& GetFogRampTex() const { return x1b8_fogVolumeRamp; }
|
||||
const boo::ObjToken<boo::ITexture>& GetRandomStaticEntropyTex() const { return m_staticEntropy->GetBooTexture(); }
|
||||
const boo::ObjToken<boo::IGraphicsBufferS>& GetScanLinesEvenVBO() const { return m_scanLinesEvenVBO; }
|
||||
const boo::ObjToken<boo::IGraphicsBufferS>& GetScanLinesOddVBO() const { return m_scanLinesOddVBO; }
|
||||
auto GetThermoPalette() const { return x288_thermoPalette.get(); }
|
||||
auto GetFogRampTex() const { return x1b8_fogVolumeRamp.get(); }
|
||||
auto GetRandomStaticEntropyTex() const { return m_staticEntropy->GetBooTexture(); }
|
||||
auto GetScanLinesEvenVBO() const { return m_scanLinesEvenVBO.get(); }
|
||||
auto GetScanLinesOddVBO() const { return m_scanLinesOddVBO.get(); }
|
||||
|
||||
const boo::ObjToken<boo::ITexture>& GetClearTexture() const { return m_clearTexture; }
|
||||
const boo::ObjToken<boo::ITexture>& GetBlackTexture() const { return m_blackTexture; }
|
||||
const boo::ObjToken<boo::ITexture>& GetWhiteTexture() const { return m_whiteTexture; }
|
||||
auto GetClearTexture() const { return m_clearTexture.get(); }
|
||||
auto GetBlackTexture() const { return m_blackTexture.get(); }
|
||||
auto GetWhiteTexture() const { return m_whiteTexture.get(); }
|
||||
|
||||
boo::ObjToken<boo::ITexture> GetColorTexture(const zeus::CColor& color);
|
||||
hsh::texture2d GetColorTexture(const zeus::CColor& color);
|
||||
|
||||
static void BindMainDrawTarget() { CGraphics::g_BooMainCommandQueue->setRenderTarget(CGraphics::g_SpareTexture); }
|
||||
void BindReflectionDrawTarget() { CGraphics::g_BooMainCommandQueue->setRenderTarget(x14c_reflectionTex); }
|
||||
void BindBallShadowIdTarget() {
|
||||
CGraphics::g_BooMainCommandQueue->setRenderTarget(m_ballShadowId);
|
||||
SetViewport(0, 0, m_ballShadowIdW, m_ballShadowIdH);
|
||||
}
|
||||
static void BindMainDrawTarget() { CGraphics::g_SpareTexture.attach(); }
|
||||
void BindReflectionDrawTarget() { x14c_reflectionTex.attach(); }
|
||||
void BindBallShadowIdTarget() { m_ballShadowId.attach(); }
|
||||
void ResolveBallShadowIdTarget() {
|
||||
CGraphics::g_BooMainCommandQueue->resolveBindTexture(
|
||||
m_ballShadowId, boo::SWindowRect(0, 0, m_ballShadowIdW, m_ballShadowIdH), false, 0, true, false);
|
||||
m_ballShadowId.resolve_color_binding(0, hsh::rect2d({0, 0}, {m_ballShadowIdW, m_ballShadowIdH}), false);
|
||||
}
|
||||
|
||||
void FindOverlappingWorldModels(std::vector<u32>& modelBits, const zeus::CAABox& aabb) const;
|
||||
|
@ -300,6 +301,8 @@ public:
|
|||
|
||||
bool IsThermalVisorActive() const { return x318_29_thermalVisor; }
|
||||
bool IsThermalVisorHotPass() const { return m_thermalHotPass; }
|
||||
|
||||
bool IsInAreaDraw() const { return x318_30_inAreaDraw; }
|
||||
};
|
||||
|
||||
} // namespace urde
|
||||
|
|
|
@ -119,12 +119,6 @@ void CGraphics::EndScene() {
|
|||
g_InterruptLastFrameUsedAbove ^= 1;
|
||||
g_LastFrameUsedAbove = g_InterruptLastFrameUsedAbove;
|
||||
|
||||
/* Flush text instance buffers just before GPU command list submission */
|
||||
CTextSupportShader::UpdateBuffers();
|
||||
|
||||
/* Same with line renderer */
|
||||
CLineRenderer::UpdateBuffers();
|
||||
|
||||
++g_FrameCounter;
|
||||
}
|
||||
|
||||
|
@ -186,24 +180,9 @@ zeus::CMatrix4f CGraphics::CalculatePerspectiveMatrix(float fovy, float aspect,
|
|||
0.f, 0.f, -fpn / fmn, -2.f * st.x18_far * st.x14_near / fmn, 0.f, 0.f, -1.f, 0.f);
|
||||
}
|
||||
|
||||
switch (g_BooPlatform) {
|
||||
case boo::IGraphicsDataFactory::Platform::OpenGL:
|
||||
default: {
|
||||
return zeus::CMatrix4f(2.f * st.x14_near / rml, 0.f, rpl / rml, 0.f, 0.f, 2.f * st.x14_near / tmb, tpb / tmb, 0.f,
|
||||
0.f, 0.f, -fpn / fmn, -2.f * st.x18_far * st.x14_near / fmn, 0.f, 0.f, -1.f, 0.f);
|
||||
}
|
||||
case boo::IGraphicsDataFactory::Platform::D3D11:
|
||||
case boo::IGraphicsDataFactory::Platform::Metal: {
|
||||
zeus::CMatrix4f mat2(2.f * st.x14_near / rml, 0.f, rpl / rml, 0.f, 0.f, 2.f * st.x14_near / tmb, tpb / tmb, 0.f,
|
||||
0.f, 0.f, st.x18_far / fmn, st.x14_near * st.x18_far / fmn, 0.f, 0.f, -1.f, 0.f);
|
||||
return PlusOneZ * mat2;
|
||||
}
|
||||
case boo::IGraphicsDataFactory::Platform::Vulkan: {
|
||||
zeus::CMatrix4f mat2(2.f * st.x14_near / rml, 0.f, rpl / rml, 0.f, 0.f, 2.f * st.x14_near / tmb, tpb / tmb, 0.f,
|
||||
0.f, 0.f, -fpn / fmn, -2.f * st.x18_far * st.x14_near / fmn, 0.f, 0.f, -1.f, 0.f);
|
||||
return VulkanCorrect * mat2;
|
||||
}
|
||||
}
|
||||
zeus::CMatrix4f mat2(2.f * st.x14_near / rml, 0.f, rpl / rml, 0.f, 0.f, 2.f * st.x14_near / tmb, tpb / tmb, 0.f,
|
||||
0.f, 0.f, -fpn / fmn, -2.f * st.x18_far * st.x14_near / fmn, 0.f, 0.f, -1.f, 0.f);
|
||||
return VulkanCorrect * mat2;
|
||||
}
|
||||
|
||||
zeus::CMatrix4f CGraphics::GetPerspectiveProjectionMatrix(bool forRenderer) {
|
||||
|
@ -221,27 +200,10 @@ zeus::CMatrix4f CGraphics::GetPerspectiveProjectionMatrix(bool forRenderer) {
|
|||
0.f, -1.f, 0.f);
|
||||
}
|
||||
|
||||
switch (g_BooPlatform) {
|
||||
case boo::IGraphicsDataFactory::Platform::OpenGL:
|
||||
default: {
|
||||
return zeus::CMatrix4f(2.f * g_Proj.x14_near / rml, 0.f, rpl / rml, 0.f, 0.f, 2.f * g_Proj.x14_near / tmb,
|
||||
tpb / tmb, 0.f, 0.f, 0.f, -fpn / fmn, -2.f * g_Proj.x18_far * g_Proj.x14_near / fmn, 0.f,
|
||||
0.f, -1.f, 0.f);
|
||||
}
|
||||
case boo::IGraphicsDataFactory::Platform::D3D11:
|
||||
case boo::IGraphicsDataFactory::Platform::Metal: {
|
||||
zeus::CMatrix4f mat2(2.f * g_Proj.x14_near / rml, 0.f, rpl / rml, 0.f, 0.f, 2.f * g_Proj.x14_near / tmb,
|
||||
tpb / tmb, 0.f, 0.f, 0.f, g_Proj.x18_far / fmn, g_Proj.x14_near * g_Proj.x18_far / fmn, 0.f,
|
||||
0.f, -1.f, 0.f);
|
||||
return PlusOneZ * mat2;
|
||||
}
|
||||
case boo::IGraphicsDataFactory::Platform::Vulkan: {
|
||||
zeus::CMatrix4f mat2(2.f * g_Proj.x14_near / rml, 0.f, rpl / rml, 0.f, 0.f, 2.f * g_Proj.x14_near / tmb,
|
||||
tpb / tmb, 0.f, 0.f, 0.f, -fpn / fmn, -2.f * g_Proj.x18_far * g_Proj.x14_near / fmn, 0.f,
|
||||
0.f, -1.f, 0.f);
|
||||
return VulkanCorrect * mat2;
|
||||
}
|
||||
}
|
||||
zeus::CMatrix4f mat2(2.f * g_Proj.x14_near / rml, 0.f, rpl / rml, 0.f, 0.f, 2.f * g_Proj.x14_near / tmb,
|
||||
tpb / tmb, 0.f, 0.f, 0.f, -fpn / fmn, -2.f * g_Proj.x18_far * g_Proj.x14_near / fmn, 0.f,
|
||||
0.f, -1.f, 0.f);
|
||||
return VulkanCorrect * mat2;
|
||||
} else {
|
||||
float rml = g_Proj.x8_right - g_Proj.x4_left;
|
||||
float rpl = g_Proj.x8_right + g_Proj.x4_left;
|
||||
|
@ -255,24 +217,9 @@ zeus::CMatrix4f CGraphics::GetPerspectiveProjectionMatrix(bool forRenderer) {
|
|||
-fpn / fmn, 0.f, 0.f, 0.f, 1.f);
|
||||
}
|
||||
|
||||
switch (g_BooPlatform) {
|
||||
case boo::IGraphicsDataFactory::Platform::OpenGL:
|
||||
default: {
|
||||
return zeus::CMatrix4f(2.f / rml, 0.f, 0.f, -rpl / rml, 0.f, 2.f / tmb, 0.f, -tpb / tmb, 0.f, 0.f, -2.f / fmn,
|
||||
-fpn / fmn, 0.f, 0.f, 0.f, 1.f);
|
||||
}
|
||||
case boo::IGraphicsDataFactory::Platform::D3D11:
|
||||
case boo::IGraphicsDataFactory::Platform::Metal: {
|
||||
zeus::CMatrix4f mat2(2.f / rml, 0.f, 0.f, -rpl / rml, 0.f, 2.f / tmb, 0.f, -tpb / tmb, 0.f, 0.f, 1.f / fmn,
|
||||
g_Proj.x14_near / fmn, 0.f, 0.f, 0.f, 1.f);
|
||||
return PlusOneZ * mat2;
|
||||
}
|
||||
case boo::IGraphicsDataFactory::Platform::Vulkan: {
|
||||
zeus::CMatrix4f mat2(2.f / rml, 0.f, 0.f, -rpl / rml, 0.f, 2.f / tmb, 0.f, -tpb / tmb, 0.f, 0.f, -2.f / fmn,
|
||||
-fpn / fmn, 0.f, 0.f, 0.f, 1.f);
|
||||
return VulkanCorrect * mat2;
|
||||
}
|
||||
}
|
||||
zeus::CMatrix4f mat2(2.f / rml, 0.f, 0.f, -rpl / rml, 0.f, 2.f / tmb, 0.f, -tpb / tmb, 0.f, 0.f, -2.f / fmn,
|
||||
-fpn / fmn, 0.f, 0.f, 0.f, 1.f);
|
||||
return VulkanCorrect * mat2;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,8 +7,7 @@
|
|||
|
||||
#include "DataSpec/DNACommon/GX.hpp"
|
||||
|
||||
#include <boo/graphicsdev/IGraphicsCommandQueue.hpp>
|
||||
#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
||||
#include "hsh/hsh.h"
|
||||
|
||||
#include <hecl/CVar.hpp>
|
||||
#include <hecl/Runtime.hpp>
|
||||
|
@ -117,19 +116,19 @@ extern SViewport g_Viewport;
|
|||
|
||||
struct SClipScreenRect {
|
||||
bool x0_valid = false;
|
||||
int x4_left = 0;
|
||||
int x8_top = 0;
|
||||
int xc_width = 0;
|
||||
int x10_height = 0;
|
||||
int x14_dstWidth = 0;
|
||||
int32_t x4_left = 0;
|
||||
int32_t x8_top = 0;
|
||||
uint32_t xc_width = 0;
|
||||
uint32_t x10_height = 0;
|
||||
uint32_t x14_dstWidth = 0;
|
||||
float x18_uvXMin = 0.f;
|
||||
float x1c_uvXMax = 0.f;
|
||||
float x20_uvYMin = 0.f;
|
||||
float x24_uvYMax = 0.f;
|
||||
|
||||
SClipScreenRect() = default;
|
||||
SClipScreenRect(bool valid, int left, int top, int width, int height, int dstWidth, float uvXMin, float uvXMax,
|
||||
float uvYMin, float uvYMax)
|
||||
SClipScreenRect(bool valid, int32_t left, int32_t top, uint32_t width, uint32_t height, uint32_t dstWidth,
|
||||
float uvXMin, float uvXMax, float uvYMin, float uvYMax)
|
||||
: x0_valid(valid)
|
||||
, x4_left(left)
|
||||
, x8_top(top)
|
||||
|
@ -141,12 +140,20 @@ struct SClipScreenRect {
|
|||
, x20_uvYMin(uvYMin)
|
||||
, x24_uvYMax(uvYMax) {}
|
||||
|
||||
SClipScreenRect(const boo::SWindowRect& rect) {
|
||||
x4_left = rect.location[0];
|
||||
x8_top = rect.location[1];
|
||||
xc_width = rect.size[0];
|
||||
x10_height = rect.size[1];
|
||||
x14_dstWidth = rect.size[0];
|
||||
SClipScreenRect(const hsh::rect2d& rect) {
|
||||
x4_left = rect.offset.x;
|
||||
x8_top = rect.offset.y;
|
||||
xc_width = rect.extent.w;
|
||||
x10_height = rect.extent.h;
|
||||
x14_dstWidth = rect.extent.w;
|
||||
}
|
||||
|
||||
SClipScreenRect(const hsh::viewport& rect) {
|
||||
x4_left = rect.x;
|
||||
x8_top = rect.y;
|
||||
xc_width = rect.width;
|
||||
x10_height = rect.height;
|
||||
x14_dstWidth = rect.width;
|
||||
}
|
||||
|
||||
SClipScreenRect(const SViewport& vp) {
|
||||
|
@ -217,14 +224,15 @@ class CTevPass {
|
|||
CTevOp x38_alphaOp;
|
||||
|
||||
public:
|
||||
CTevPass(const ColorPass& colPass, const AlphaPass& alphaPass, const CTevOp& colorOp = CTevOp(), const CTevOp alphaOp = CTevOp())
|
||||
: x0_id(++sNextUniquePass)
|
||||
, x4_colorPass(colPass)
|
||||
, x14_alphaPass(alphaPass)
|
||||
, x24_colorOp(colorOp)
|
||||
, x38_alphaOp(alphaOp) {}
|
||||
};
|
||||
CTevPass(const ColorPass& colPass, const AlphaPass& alphaPass, const CTevOp& colorOp = CTevOp(),
|
||||
const CTevOp alphaOp = CTevOp())
|
||||
: x0_id(++sNextUniquePass)
|
||||
, x4_colorPass(colPass)
|
||||
, x14_alphaPass(alphaPass)
|
||||
, x24_colorOp(colorOp)
|
||||
, x38_alphaOp(alphaOp) {}
|
||||
};
|
||||
}; // namespace CTevCombiners
|
||||
|
||||
class CGraphics {
|
||||
public:
|
||||
|
@ -239,7 +247,7 @@ public:
|
|||
};
|
||||
|
||||
struct CFogState {
|
||||
zeus::CColor m_color;
|
||||
hsh::float4 m_color;
|
||||
float m_A = 0.f;
|
||||
float m_B = 0.5f;
|
||||
float m_C = 0.f;
|
||||
|
@ -311,51 +319,24 @@ public:
|
|||
static u32 g_FrameCounter;
|
||||
static u32 GetFrameCounter() { return g_FrameCounter; }
|
||||
|
||||
static boo::IGraphicsDataFactory::Platform g_BooPlatform;
|
||||
static const boo::SystemChar* g_BooPlatformName;
|
||||
static boo::IGraphicsDataFactory* g_BooFactory;
|
||||
static boo::IGraphicsCommandQueue* g_BooMainCommandQueue;
|
||||
static boo::ObjToken<boo::ITextureR> g_SpareTexture;
|
||||
static hsh::owner<hsh::render_texture2d> g_SpareTexture;
|
||||
|
||||
static const std::array<zeus::CMatrix3f, 6> skCubeBasisMats;
|
||||
|
||||
static void InitializeBoo(boo::IGraphicsDataFactory* factory, boo::IGraphicsCommandQueue* cc,
|
||||
const boo::ObjToken<boo::ITextureR>& spareTex) {
|
||||
g_BooPlatform = factory->platform();
|
||||
g_BooPlatformName = factory->platformName();
|
||||
g_BooFactory = factory;
|
||||
g_BooMainCommandQueue = cc;
|
||||
g_SpareTexture = spareTex;
|
||||
}
|
||||
static void InitializeBoo(hsh::surface surface) { g_SpareTexture = hsh::create_render_texture2d(surface, 4, 1); }
|
||||
|
||||
static void ShutdownBoo() {
|
||||
g_BooFactory = nullptr;
|
||||
g_BooMainCommandQueue = nullptr;
|
||||
g_SpareTexture.reset();
|
||||
}
|
||||
static void ShutdownBoo() { g_SpareTexture.reset(); }
|
||||
|
||||
static const boo::SystemChar* PlatformName() { return g_BooPlatformName; }
|
||||
|
||||
static void CommitResources(const boo::FactoryCommitFunc& commitFunc __BooTraceArgs) {
|
||||
g_BooFactory->commitTransaction(commitFunc __BooTraceArgsUse);
|
||||
}
|
||||
|
||||
static void SetShaderDataBinding(const boo::ObjToken<boo::IShaderDataBinding>& binding) {
|
||||
g_BooMainCommandQueue->setShaderDataBinding(binding);
|
||||
}
|
||||
static void ResolveSpareTexture(const SClipScreenRect& rect, int bindIdx = 0, bool clearDepth = false) {
|
||||
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);
|
||||
hsh::rect2d wrect = {{rect.x4_left, rect.x8_top}, {rect.xc_width, rect.x10_height}};
|
||||
g_SpareTexture.resolve_color_binding(bindIdx, wrect);
|
||||
if (clearDepth)
|
||||
hsh::clear_attachments(false, true);
|
||||
}
|
||||
static void ResolveSpareDepth(const SClipScreenRect& rect, int bindIdx = 0) {
|
||||
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);
|
||||
hsh::rect2d wrect = {{rect.x4_left, rect.x8_top}, {rect.xc_width, rect.x10_height}};
|
||||
g_SpareTexture.resolve_depth_binding(bindIdx, wrect);
|
||||
}
|
||||
static void DrawInstances(size_t start, size_t count, size_t instCount, size_t startInst = 0) {
|
||||
g_BooMainCommandQueue->drawInstances(start, count, instCount, startInst);
|
||||
}
|
||||
static void DrawArray(size_t start, size_t count) { g_BooMainCommandQueue->draw(start, count); }
|
||||
static void DrawArrayIndexed(size_t start, size_t count) { g_BooMainCommandQueue->drawIndexed(start, count); }\
|
||||
|
||||
static const CTevCombiners::CTevPass sTevPass805a564c;
|
||||
static const CTevCombiners::CTevPass sTevPass805a5698;
|
||||
|
@ -409,9 +390,136 @@ public:
|
|||
m_vec.emplace_back(std::forward<_Args>(args)...);
|
||||
}
|
||||
|
||||
void Draw() const { CGraphics::DrawArray(m_start, m_vec.size() - m_start); }
|
||||
template <class T>
|
||||
void Draw(T& binding) const {
|
||||
binding.draw(m_start, m_vec.size() - m_start);
|
||||
}
|
||||
};
|
||||
|
||||
struct ViewBlock {
|
||||
hsh::float4x4 m_mv;
|
||||
hsh::float4 m_color = zeus::skWhite;
|
||||
void setViewRect(const hsh::rect2d& root, const hsh::rect2d& sub) {
|
||||
m_mv[0][0] = 2.0f / root.extent.w;
|
||||
m_mv[1][1] = 2.0f / root.extent.h;
|
||||
m_mv[3][0] = sub.offset.x * m_mv[0][0] - 1.0f;
|
||||
m_mv[3][1] = sub.offset.y * m_mv[1][1] - 1.0f;
|
||||
}
|
||||
void finalAssign(const ViewBlock& other) {
|
||||
m_mv = other.m_mv;
|
||||
m_color = other.m_color;
|
||||
}
|
||||
};
|
||||
|
||||
struct TexUVVert {
|
||||
hsh::float3 m_pos;
|
||||
hsh::float2 m_uv;
|
||||
};
|
||||
|
||||
enum class AlphaMode { NoAlpha, AlphaWrite, AlphaReplace };
|
||||
|
||||
template <AlphaMode Alpha, hsh::BlendFactor BF>
|
||||
struct AlphaSrc {
|
||||
static constexpr hsh::BlendFactor Factor = BF;
|
||||
};
|
||||
template <hsh::BlendFactor BF>
|
||||
struct AlphaSrc<AlphaMode::AlphaReplace, BF> {
|
||||
static constexpr hsh::BlendFactor Factor = hsh::One;
|
||||
};
|
||||
|
||||
template <AlphaMode Alpha, hsh::BlendFactor BF>
|
||||
struct AlphaDst {
|
||||
static constexpr hsh::BlendFactor Factor = BF;
|
||||
};
|
||||
template <hsh::BlendFactor BF>
|
||||
struct AlphaDst<AlphaMode::AlphaReplace, BF> {
|
||||
static constexpr hsh::BlendFactor Factor = hsh::Zero;
|
||||
};
|
||||
|
||||
template <AlphaMode Alpha = AlphaMode::NoAlpha>
|
||||
using BlendAttachmentExt =
|
||||
hsh::pipeline::color_attachment<hsh::SrcAlpha, hsh::InvSrcAlpha, hsh::Add, AlphaSrc<Alpha, hsh::SrcAlpha>::Factor,
|
||||
AlphaDst<Alpha, hsh::InvSrcAlpha>::Factor, hsh::Add,
|
||||
hsh::ColorComponentFlags(
|
||||
hsh::CC_Red | hsh::CC_Green | hsh::CC_Blue |
|
||||
(Alpha != AlphaMode::NoAlpha ? hsh::CC_Alpha : hsh::ColorComponentFlags()))>;
|
||||
template <AlphaMode Alpha = AlphaMode::NoAlpha>
|
||||
using AdditiveAttachmentExt =
|
||||
hsh::pipeline::color_attachment<hsh::SrcAlpha, hsh::One, hsh::Add, AlphaSrc<Alpha, hsh::SrcAlpha>::Factor,
|
||||
AlphaDst<Alpha, hsh::One>::Factor, hsh::Add,
|
||||
hsh::ColorComponentFlags(
|
||||
hsh::CC_Red | hsh::CC_Green | hsh::CC_Blue |
|
||||
(Alpha != AlphaMode::NoAlpha ? hsh::CC_Alpha : hsh::ColorComponentFlags()))>;
|
||||
template <AlphaMode Alpha = AlphaMode::NoAlpha>
|
||||
using MultiplyAttachmentExt =
|
||||
hsh::pipeline::color_attachment<hsh::Zero, hsh::SrcColor, hsh::Add, AlphaSrc<Alpha, hsh::Zero>::Factor,
|
||||
AlphaDst<Alpha, hsh::SrcAlpha>::Factor, hsh::Add,
|
||||
hsh::ColorComponentFlags(
|
||||
hsh::CC_Red | hsh::CC_Green | hsh::CC_Blue |
|
||||
(Alpha != AlphaMode::NoAlpha ? hsh::CC_Alpha : hsh::ColorComponentFlags()))>;
|
||||
template <AlphaMode Alpha = AlphaMode::NoAlpha>
|
||||
using SubtractAttachmentExt = hsh::pipeline::color_attachment<
|
||||
hsh::SrcAlpha, hsh::One, hsh::ReverseSubtract, AlphaSrc<Alpha, hsh::SrcAlpha>::Factor,
|
||||
AlphaDst<Alpha, hsh::One>::Factor, Alpha == AlphaMode::AlphaReplace ? hsh::Add : hsh::ReverseSubtract,
|
||||
hsh::ColorComponentFlags(hsh::CC_Red | hsh::CC_Green | hsh::CC_Blue |
|
||||
(Alpha != AlphaMode::NoAlpha ? hsh::CC_Alpha : hsh::ColorComponentFlags()))>;
|
||||
|
||||
template <AlphaMode Alpha = AlphaMode::NoAlpha>
|
||||
using InvDstMultiplyAttachmentExt =
|
||||
hsh::pipeline::color_attachment<hsh::Zero, hsh::InvDstColor, hsh::Add, AlphaSrc<Alpha, hsh::Zero>::Factor,
|
||||
AlphaDst<Alpha, hsh::InvDstAlpha>::Factor, hsh::Add,
|
||||
hsh::ColorComponentFlags(
|
||||
hsh::CC_Red | hsh::CC_Green | hsh::CC_Blue |
|
||||
(Alpha != AlphaMode::NoAlpha ? hsh::CC_Alpha : hsh::ColorComponentFlags()))>;
|
||||
|
||||
template <AlphaMode Alpha = AlphaMode::NoAlpha>
|
||||
using NoColorAttachmentExt =
|
||||
hsh::pipeline::color_attachment<hsh::Zero, hsh::SrcColor, hsh::Add, AlphaSrc<Alpha, hsh::Zero>::Factor,
|
||||
AlphaDst<Alpha, hsh::SrcAlpha>::Factor, hsh::Add,
|
||||
hsh::ColorComponentFlags(
|
||||
(Alpha != AlphaMode::NoAlpha ? hsh::CC_Alpha : hsh::ColorComponentFlags()))>;
|
||||
|
||||
template <bool AlphaWrite = false>
|
||||
using BlendAttachment = BlendAttachmentExt<AlphaWrite ? AlphaMode::AlphaWrite : AlphaMode::NoAlpha>;
|
||||
template <bool AlphaWrite = false>
|
||||
using AdditiveAttachment = AdditiveAttachmentExt<AlphaWrite ? AlphaMode::AlphaWrite : AlphaMode::NoAlpha>;
|
||||
template <bool AlphaWrite = false>
|
||||
using MultiplyAttachment = MultiplyAttachmentExt<AlphaWrite ? AlphaMode::AlphaWrite : AlphaMode::NoAlpha>;
|
||||
template <bool AlphaWrite = false>
|
||||
using SubtractAttachment = SubtractAttachmentExt<AlphaWrite ? AlphaMode::AlphaWrite : AlphaMode::NoAlpha>;
|
||||
template <bool AlphaWrite = false>
|
||||
using InvDstMultiplyAttachment = InvDstMultiplyAttachmentExt<AlphaWrite ? AlphaMode::AlphaWrite : AlphaMode::NoAlpha>;
|
||||
template <bool AlphaWrite = false>
|
||||
using NoColorAttachment = NoColorAttachmentExt<AlphaWrite ? AlphaMode::AlphaWrite : AlphaMode::NoAlpha>;
|
||||
|
||||
#define FOG_SHADER(fog) \
|
||||
float fogZ; \
|
||||
float fogF = hsh::saturate(((fog).m_A / ((fog).m_B - this->position.z)) - (fog).m_C); \
|
||||
switch ((fog).m_mode) { \
|
||||
case ERglFogMode::PerspLin: \
|
||||
fogZ = fogF; \
|
||||
break; \
|
||||
case ERglFogMode::PerspExp: \
|
||||
fogZ = 1.0 - hsh::exp2(-8.0 * fogF); \
|
||||
break; \
|
||||
case ERglFogMode::PerspExp2: \
|
||||
fogZ = 1.0 - hsh::exp2(-8.0 * fogF * fogF); \
|
||||
break; \
|
||||
case ERglFogMode::PerspRevExp: \
|
||||
fogZ = hsh::exp2(-8.0 * (1.0 - fogF)); \
|
||||
break; \
|
||||
case ERglFogMode::PerspRevExp2: \
|
||||
fogF = 1.0 - fogF; \
|
||||
fogZ = hsh::exp2(-8.0 * fogF * fogF); \
|
||||
break; \
|
||||
default: \
|
||||
fogZ = 0.0; \
|
||||
break; \
|
||||
}
|
||||
|
||||
#define FOG_OUT(out, fog, colorIn) \
|
||||
out = hsh::float4(hsh::lerp((colorIn), (fog).m_color, hsh::saturate(fogZ)).xyz(), (colorIn).w);
|
||||
|
||||
#ifdef BOO_GRAPHICS_DEBUG_GROUPS
|
||||
class GraphicsDebugGroup {
|
||||
/* Stack only */
|
||||
|
@ -419,14 +527,13 @@ class GraphicsDebugGroup {
|
|||
void operator delete(void*);
|
||||
void* operator new[](size_t);
|
||||
void operator delete[](void*);
|
||||
|
||||
public:
|
||||
explicit GraphicsDebugGroup(const char* name, const zeus::CColor& color = zeus::skWhite) {
|
||||
zeus::simd_floats f(color.mSimd);
|
||||
CGraphics::g_BooMainCommandQueue->pushDebugGroup(name, f.array());
|
||||
}
|
||||
~GraphicsDebugGroup() {
|
||||
CGraphics::g_BooMainCommandQueue->popDebugGroup();
|
||||
}
|
||||
~GraphicsDebugGroup() { CGraphics::g_BooMainCommandQueue->popDebugGroup(); }
|
||||
};
|
||||
#define SCOPED_GRAPHICS_DEBUG_GROUP(...) GraphicsDebugGroup _GfxDbg_(__VA_ARGS__);
|
||||
#else
|
||||
|
|
|
@ -7,21 +7,8 @@
|
|||
namespace urde {
|
||||
logvisor::Module LineRendererLog("urde::CLineRenderer");
|
||||
|
||||
void CLineRenderer::Initialize() { CLineRendererShaders::Initialize(); }
|
||||
|
||||
void CLineRenderer::Shutdown() {
|
||||
CLineRendererShaders::Shutdown();
|
||||
s_vertPoolTex.doDestroy();
|
||||
s_vertPoolNoTex.doDestroy();
|
||||
s_uniformPool.doDestroy();
|
||||
}
|
||||
|
||||
hecl::VertexBufferPool<CLineRenderer::SDrawVertTex> CLineRenderer::s_vertPoolTex = {};
|
||||
hecl::VertexBufferPool<CLineRenderer::SDrawVertNoTex> CLineRenderer::s_vertPoolNoTex = {};
|
||||
hecl::UniformBufferPool<CLineRenderer::SDrawUniform> CLineRenderer::s_uniformPool = {};
|
||||
|
||||
CLineRenderer::CLineRenderer(boo::IGraphicsDataFactory::Context& ctx, EPrimitiveMode mode, u32 maxVerts,
|
||||
const boo::ObjToken<boo::ITexture>& texture, bool additive, bool zTest, bool zGEqual)
|
||||
CLineRenderer::CLineRenderer(EPrimitiveMode mode, u32 maxVerts, hsh::texture2d texture,
|
||||
bool additive, hsh::Compare zComp)
|
||||
: m_mode(mode), m_maxVerts(maxVerts) {
|
||||
if (maxVerts < 2) {
|
||||
LineRendererLog.report(logvisor::Fatal, FMT_STRING(_SYS_STR("maxVerts < 2, maxVerts = {}")), maxVerts);
|
||||
|
@ -41,48 +28,14 @@ CLineRenderer::CLineRenderer(boo::IGraphicsDataFactory::Context& ctx, EPrimitive
|
|||
}
|
||||
|
||||
if (texture) {
|
||||
m_vertBufTex = s_vertPoolTex.allocateBlock(CGraphics::g_BooFactory, maxTriVerts);
|
||||
m_vertBuf = hsh::create_dynamic_vertex_buffer<SDrawVertTex>(maxTriVerts);
|
||||
} else {
|
||||
m_vertBufNoTex = s_vertPoolNoTex.allocateBlock(CGraphics::g_BooFactory, maxTriVerts);
|
||||
m_vertBuf = hsh::create_dynamic_vertex_buffer<SDrawVertNoTex>(maxTriVerts);
|
||||
}
|
||||
|
||||
m_uniformBuf = s_uniformPool.allocateBlock(CGraphics::g_BooFactory);
|
||||
m_uniformBuf = hsh::create_dynamic_uniform_buffer<SDrawUniform>();
|
||||
|
||||
CLineRendererShaders::BuildShaderDataBinding(ctx, *this, texture, additive, zTest, zGEqual);
|
||||
}
|
||||
|
||||
CLineRenderer::CLineRenderer(EPrimitiveMode mode, u32 maxVerts, const boo::ObjToken<boo::ITexture>& texture,
|
||||
bool additive, bool zTest, bool zGEqual)
|
||||
: m_mode(mode), m_maxVerts(maxVerts) {
|
||||
if (maxVerts < 2) {
|
||||
LineRendererLog.report(logvisor::Fatal, FMT_STRING(_SYS_STR("maxVerts < 2, maxVerts = {}")), maxVerts);
|
||||
return;
|
||||
}
|
||||
m_textured = bool(texture);
|
||||
|
||||
u32 maxTriVerts = 0;
|
||||
switch (mode) {
|
||||
case EPrimitiveMode::Lines:
|
||||
case EPrimitiveMode::LineStrip:
|
||||
maxTriVerts = maxVerts * 4;
|
||||
break;
|
||||
case EPrimitiveMode::LineLoop:
|
||||
maxTriVerts = maxVerts * 4 + 4;
|
||||
break;
|
||||
}
|
||||
|
||||
if (texture) {
|
||||
m_vertBufTex = s_vertPoolTex.allocateBlock(CGraphics::g_BooFactory, maxTriVerts);
|
||||
} else {
|
||||
m_vertBufNoTex = s_vertPoolNoTex.allocateBlock(CGraphics::g_BooFactory, maxTriVerts);
|
||||
}
|
||||
|
||||
m_uniformBuf = s_uniformPool.allocateBlock(CGraphics::g_BooFactory);
|
||||
|
||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
||||
CLineRendererShaders::BuildShaderDataBinding(ctx, *this, texture, additive, zTest, zGEqual);
|
||||
return true;
|
||||
} BooTrace);
|
||||
CLineRendererShaders::BindShader(*this, texture, additive, zComp);
|
||||
}
|
||||
|
||||
rstl::reserved_vector<CLineRenderer::SDrawVertTex, 1024> CLineRenderer::g_StaticLineVertsTex = {};
|
||||
|
@ -149,12 +102,12 @@ void CLineRenderer::AddVertex(const zeus::CVector3f& position, const zeus::CColo
|
|||
if (m_mode == EPrimitiveMode::Lines) {
|
||||
if (m_nextVert & 1) {
|
||||
g_StaticLineVertsTex.push_back(g_StaticLineVertsTex.back());
|
||||
g_StaticLineVertsTex.push_back({zeus::CVector4f::ToClip(m_lastPos + dvb, m_lastW), m_lastColor, m_lastUV});
|
||||
g_StaticLineVertsTex.emplace_back(zeus::CVector4f::ToClip(m_lastPos + dvb, m_lastW), m_lastColor, m_lastUV);
|
||||
g_StaticLineVertsTex.push_back(g_StaticLineVertsTex.back());
|
||||
g_StaticLineVertsTex.push_back({zeus::CVector4f::ToClip(m_lastPos - dvb, m_lastW), m_lastColor, m_lastUV});
|
||||
g_StaticLineVertsTex.emplace_back(zeus::CVector4f::ToClip(m_lastPos - dvb, m_lastW), m_lastColor, m_lastUV);
|
||||
} else {
|
||||
g_StaticLineVertsTex.push_back({zeus::CVector4f::ToClip(m_lastPos + dva, m_lastW), m_lastColor, m_lastUV});
|
||||
g_StaticLineVertsTex.push_back({zeus::CVector4f::ToClip(m_lastPos - dva, m_lastW), m_lastColor, m_lastUV});
|
||||
g_StaticLineVertsTex.emplace_back(zeus::CVector4f::ToClip(m_lastPos + dva, m_lastW), m_lastColor, m_lastUV);
|
||||
g_StaticLineVertsTex.emplace_back(zeus::CVector4f::ToClip(m_lastPos - dva, m_lastW), m_lastColor, m_lastUV);
|
||||
}
|
||||
} else {
|
||||
zeus::CVector3f intersect1;
|
||||
|
@ -172,25 +125,25 @@ void CLineRenderer::AddVertex(const zeus::CVector3f& position, const zeus::CColo
|
|||
if (good1 && good2) {
|
||||
intersect1.z() = float(m_lastPos.z());
|
||||
intersect2.z() = float(m_lastPos.z());
|
||||
g_StaticLineVertsTex.push_back({zeus::CVector4f::ToClip(intersect1, m_lastW), m_lastColor, m_lastUV});
|
||||
g_StaticLineVertsTex.push_back({zeus::CVector4f::ToClip(intersect2, m_lastW), m_lastColor, m_lastUV});
|
||||
g_StaticLineVertsTex.emplace_back(zeus::CVector4f::ToClip(intersect1, m_lastW), m_lastColor, m_lastUV);
|
||||
g_StaticLineVertsTex.emplace_back(zeus::CVector4f::ToClip(intersect2, m_lastW), m_lastColor, m_lastUV);
|
||||
} else {
|
||||
g_StaticLineVertsTex.push_back({zeus::CVector4f::ToClip(m_lastPos + dva, m_lastW), m_lastColor, m_lastUV});
|
||||
g_StaticLineVertsTex.push_back({zeus::CVector4f::ToClip(m_lastPos - dva, m_lastW), m_lastColor, m_lastUV});
|
||||
g_StaticLineVertsTex.push_back({zeus::CVector4f::ToClip(m_lastPos + dvb, m_lastW), m_lastColor, m_lastUV});
|
||||
g_StaticLineVertsTex.push_back({zeus::CVector4f::ToClip(m_lastPos - dvb, m_lastW), m_lastColor, m_lastUV});
|
||||
g_StaticLineVertsTex.emplace_back(zeus::CVector4f::ToClip(m_lastPos + dva, m_lastW), m_lastColor, m_lastUV);
|
||||
g_StaticLineVertsTex.emplace_back(zeus::CVector4f::ToClip(m_lastPos - dva, m_lastW), m_lastColor, m_lastUV);
|
||||
g_StaticLineVertsTex.emplace_back(zeus::CVector4f::ToClip(m_lastPos + dvb, m_lastW), m_lastColor, m_lastUV);
|
||||
g_StaticLineVertsTex.emplace_back(zeus::CVector4f::ToClip(m_lastPos - dvb, m_lastW), m_lastColor, m_lastUV);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (m_mode == EPrimitiveMode::Lines) {
|
||||
if (m_nextVert & 1) {
|
||||
g_StaticLineVertsNoTex.push_back(g_StaticLineVertsNoTex.back());
|
||||
g_StaticLineVertsNoTex.push_back({zeus::CVector4f::ToClip(m_lastPos + dvb, m_lastW), m_lastColor});
|
||||
g_StaticLineVertsNoTex.emplace_back(zeus::CVector4f::ToClip(m_lastPos + dvb, m_lastW), m_lastColor);
|
||||
g_StaticLineVertsNoTex.push_back(g_StaticLineVertsNoTex.back());
|
||||
g_StaticLineVertsNoTex.push_back({zeus::CVector4f::ToClip(m_lastPos - dvb, m_lastW), m_lastColor});
|
||||
g_StaticLineVertsNoTex.emplace_back(zeus::CVector4f::ToClip(m_lastPos - dvb, m_lastW), m_lastColor);
|
||||
} else {
|
||||
g_StaticLineVertsNoTex.push_back({zeus::CVector4f::ToClip(m_lastPos + dva, m_lastW), m_lastColor});
|
||||
g_StaticLineVertsNoTex.push_back({zeus::CVector4f::ToClip(m_lastPos - dva, m_lastW), m_lastColor});
|
||||
g_StaticLineVertsNoTex.emplace_back(zeus::CVector4f::ToClip(m_lastPos + dva, m_lastW), m_lastColor);
|
||||
g_StaticLineVertsNoTex.emplace_back(zeus::CVector4f::ToClip(m_lastPos - dva, m_lastW), m_lastColor);
|
||||
}
|
||||
} else {
|
||||
zeus::CVector3f intersect1;
|
||||
|
@ -208,13 +161,13 @@ void CLineRenderer::AddVertex(const zeus::CVector3f& position, const zeus::CColo
|
|||
if (good1 && good2) {
|
||||
intersect1.z() = float(m_lastPos.z());
|
||||
intersect2.z() = float(m_lastPos.z());
|
||||
g_StaticLineVertsNoTex.push_back({zeus::CVector4f::ToClip(intersect1, m_lastW), m_lastColor});
|
||||
g_StaticLineVertsNoTex.push_back({zeus::CVector4f::ToClip(intersect2, m_lastW), m_lastColor});
|
||||
g_StaticLineVertsNoTex.emplace_back(zeus::CVector4f::ToClip(intersect1, m_lastW), m_lastColor);
|
||||
g_StaticLineVertsNoTex.emplace_back(zeus::CVector4f::ToClip(intersect2, m_lastW), m_lastColor);
|
||||
} else {
|
||||
g_StaticLineVertsNoTex.push_back({zeus::CVector4f::ToClip(m_lastPos + dva, m_lastW), m_lastColor});
|
||||
g_StaticLineVertsNoTex.push_back({zeus::CVector4f::ToClip(m_lastPos - dva, m_lastW), m_lastColor});
|
||||
g_StaticLineVertsNoTex.push_back({zeus::CVector4f::ToClip(m_lastPos + dvb, m_lastW), m_lastColor});
|
||||
g_StaticLineVertsNoTex.push_back({zeus::CVector4f::ToClip(m_lastPos - dvb, m_lastW), m_lastColor});
|
||||
g_StaticLineVertsNoTex.emplace_back(zeus::CVector4f::ToClip(m_lastPos + dva, m_lastW), m_lastColor);
|
||||
g_StaticLineVertsNoTex.emplace_back(zeus::CVector4f::ToClip(m_lastPos - dva, m_lastW), m_lastColor);
|
||||
g_StaticLineVertsNoTex.emplace_back(zeus::CVector4f::ToClip(m_lastPos + dvb, m_lastW), m_lastColor);
|
||||
g_StaticLineVertsNoTex.emplace_back(zeus::CVector4f::ToClip(m_lastPos - dvb, m_lastW), m_lastColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -225,11 +178,11 @@ void CLineRenderer::AddVertex(const zeus::CVector3f& position, const zeus::CColo
|
|||
dv = dv.normalized().perpendicularVector() * m_lastWidth;
|
||||
dv.x() /= CGraphics::g_ProjAspect;
|
||||
if (m_textured) {
|
||||
g_StaticLineVertsTex.push_back({zeus::CVector4f::ToClip(m_lastPos + dv, m_lastW), m_lastColor, m_lastUV});
|
||||
g_StaticLineVertsTex.push_back({zeus::CVector4f::ToClip(m_lastPos - dv, m_lastW), m_lastColor, m_lastUV});
|
||||
g_StaticLineVertsTex.emplace_back(zeus::CVector4f::ToClip(m_lastPos + dv, m_lastW), m_lastColor, m_lastUV);
|
||||
g_StaticLineVertsTex.emplace_back(zeus::CVector4f::ToClip(m_lastPos - dv, m_lastW), m_lastColor, m_lastUV);
|
||||
} else {
|
||||
g_StaticLineVertsNoTex.push_back({zeus::CVector4f::ToClip(m_lastPos + dv, m_lastW), m_lastColor});
|
||||
g_StaticLineVertsNoTex.push_back({zeus::CVector4f::ToClip(m_lastPos - dv, m_lastW), m_lastColor});
|
||||
g_StaticLineVertsNoTex.emplace_back(zeus::CVector4f::ToClip(m_lastPos + dv, m_lastW), m_lastColor);
|
||||
g_StaticLineVertsNoTex.emplace_back(zeus::CVector4f::ToClip(m_lastPos - dv, m_lastW), m_lastColor);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -276,25 +229,25 @@ void CLineRenderer::Render(bool alphaWrite, const zeus::CColor& moduColor) {
|
|||
if (good1 && good2) {
|
||||
intersect1.z() = float(m_lastPos.z());
|
||||
intersect2.z() = float(m_lastPos.z());
|
||||
g_StaticLineVertsTex.push_back({zeus::CVector4f::ToClip(intersect1, m_lastW), m_lastColor, m_lastUV});
|
||||
g_StaticLineVertsTex.push_back({zeus::CVector4f::ToClip(intersect2, m_lastW), m_lastColor, m_lastUV});
|
||||
g_StaticLineVertsTex.emplace_back(zeus::CVector4f::ToClip(intersect1, m_lastW), m_lastColor, m_lastUV);
|
||||
g_StaticLineVertsTex.emplace_back(zeus::CVector4f::ToClip(intersect2, m_lastW), m_lastColor, m_lastUV);
|
||||
} else {
|
||||
g_StaticLineVertsTex.push_back({zeus::CVector4f::ToClip(m_lastPos + dva, m_lastW), m_lastColor, m_lastUV});
|
||||
g_StaticLineVertsTex.push_back({zeus::CVector4f::ToClip(m_lastPos - dva, m_lastW), m_lastColor, m_lastUV});
|
||||
g_StaticLineVertsTex.push_back({zeus::CVector4f::ToClip(m_lastPos + dvb, m_lastW), m_lastColor, m_lastUV});
|
||||
g_StaticLineVertsTex.push_back({zeus::CVector4f::ToClip(m_lastPos - dvb, m_lastW), m_lastColor, m_lastUV});
|
||||
g_StaticLineVertsTex.emplace_back(zeus::CVector4f::ToClip(m_lastPos + dva, m_lastW), m_lastColor, m_lastUV);
|
||||
g_StaticLineVertsTex.emplace_back(zeus::CVector4f::ToClip(m_lastPos - dva, m_lastW), m_lastColor, m_lastUV);
|
||||
g_StaticLineVertsTex.emplace_back(zeus::CVector4f::ToClip(m_lastPos + dvb, m_lastW), m_lastColor, m_lastUV);
|
||||
g_StaticLineVertsTex.emplace_back(zeus::CVector4f::ToClip(m_lastPos - dvb, m_lastW), m_lastColor, m_lastUV);
|
||||
}
|
||||
} else {
|
||||
if (good1 && good2) {
|
||||
intersect1.z() = float(m_lastPos.z());
|
||||
intersect2.z() = float(m_lastPos.z());
|
||||
g_StaticLineVertsNoTex.push_back({zeus::CVector4f::ToClip(intersect1, m_lastW), m_lastColor});
|
||||
g_StaticLineVertsNoTex.push_back({zeus::CVector4f::ToClip(intersect2, m_lastW), m_lastColor});
|
||||
g_StaticLineVertsNoTex.emplace_back(zeus::CVector4f::ToClip(intersect1, m_lastW), m_lastColor);
|
||||
g_StaticLineVertsNoTex.emplace_back(zeus::CVector4f::ToClip(intersect2, m_lastW), m_lastColor);
|
||||
} else {
|
||||
g_StaticLineVertsNoTex.push_back({zeus::CVector4f::ToClip(m_lastPos + dva, m_lastW), m_lastColor});
|
||||
g_StaticLineVertsNoTex.push_back({zeus::CVector4f::ToClip(m_lastPos - dva, m_lastW), m_lastColor});
|
||||
g_StaticLineVertsNoTex.push_back({zeus::CVector4f::ToClip(m_lastPos + dvb, m_lastW), m_lastColor});
|
||||
g_StaticLineVertsNoTex.push_back({zeus::CVector4f::ToClip(m_lastPos - dvb, m_lastW), m_lastColor});
|
||||
g_StaticLineVertsNoTex.emplace_back(zeus::CVector4f::ToClip(m_lastPos + dva, m_lastW), m_lastColor);
|
||||
g_StaticLineVertsNoTex.emplace_back(zeus::CVector4f::ToClip(m_lastPos - dva, m_lastW), m_lastColor);
|
||||
g_StaticLineVertsNoTex.emplace_back(zeus::CVector4f::ToClip(m_lastPos + dvb, m_lastW), m_lastColor);
|
||||
g_StaticLineVertsNoTex.emplace_back(zeus::CVector4f::ToClip(m_lastPos - dvb, m_lastW), m_lastColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -327,25 +280,25 @@ void CLineRenderer::Render(bool alphaWrite, const zeus::CColor& moduColor) {
|
|||
if (good1 && good2) {
|
||||
intersect1.z() = float(m_firstPos.z());
|
||||
intersect2.z() = float(m_firstPos.z());
|
||||
g_StaticLineVertsTex.push_back({zeus::CVector4f::ToClip(intersect1, m_lastW), m_lastColor, m_lastUV});
|
||||
g_StaticLineVertsTex.push_back({zeus::CVector4f::ToClip(intersect2, m_lastW), m_lastColor, m_lastUV});
|
||||
g_StaticLineVertsTex.emplace_back(zeus::CVector4f::ToClip(intersect1, m_lastW), m_lastColor, m_lastUV);
|
||||
g_StaticLineVertsTex.emplace_back(zeus::CVector4f::ToClip(intersect2, m_lastW), m_lastColor, m_lastUV);
|
||||
} else {
|
||||
g_StaticLineVertsTex.push_back({zeus::CVector4f::ToClip(m_firstPos + dva, m_lastW), m_lastColor, m_lastUV});
|
||||
g_StaticLineVertsTex.push_back({zeus::CVector4f::ToClip(m_firstPos - dva, m_lastW), m_lastColor, m_lastUV});
|
||||
g_StaticLineVertsTex.push_back({zeus::CVector4f::ToClip(m_firstPos + dvb, m_lastW), m_lastColor, m_lastUV});
|
||||
g_StaticLineVertsTex.push_back({zeus::CVector4f::ToClip(m_firstPos - dvb, m_lastW), m_lastColor, m_lastUV});
|
||||
g_StaticLineVertsTex.emplace_back(zeus::CVector4f::ToClip(m_firstPos + dva, m_lastW), m_lastColor, m_lastUV);
|
||||
g_StaticLineVertsTex.emplace_back(zeus::CVector4f::ToClip(m_firstPos - dva, m_lastW), m_lastColor, m_lastUV);
|
||||
g_StaticLineVertsTex.emplace_back(zeus::CVector4f::ToClip(m_firstPos + dvb, m_lastW), m_lastColor, m_lastUV);
|
||||
g_StaticLineVertsTex.emplace_back(zeus::CVector4f::ToClip(m_firstPos - dvb, m_lastW), m_lastColor, m_lastUV);
|
||||
}
|
||||
} else {
|
||||
if (good1 && good2) {
|
||||
intersect1.z() = float(m_firstPos.z());
|
||||
intersect2.z() = float(m_firstPos.z());
|
||||
g_StaticLineVertsNoTex.push_back({zeus::CVector4f::ToClip(intersect1, m_lastW), m_lastColor});
|
||||
g_StaticLineVertsNoTex.push_back({zeus::CVector4f::ToClip(intersect2, m_lastW), m_lastColor});
|
||||
g_StaticLineVertsNoTex.emplace_back(zeus::CVector4f::ToClip(intersect1, m_lastW), m_lastColor);
|
||||
g_StaticLineVertsNoTex.emplace_back(zeus::CVector4f::ToClip(intersect2, m_lastW), m_lastColor);
|
||||
} else {
|
||||
g_StaticLineVertsNoTex.push_back({zeus::CVector4f::ToClip(m_firstPos + dva, m_lastW), m_lastColor});
|
||||
g_StaticLineVertsNoTex.push_back({zeus::CVector4f::ToClip(m_firstPos - dva, m_lastW), m_lastColor});
|
||||
g_StaticLineVertsNoTex.push_back({zeus::CVector4f::ToClip(m_firstPos + dvb, m_lastW), m_lastColor});
|
||||
g_StaticLineVertsNoTex.push_back({zeus::CVector4f::ToClip(m_firstPos - dvb, m_lastW), m_lastColor});
|
||||
g_StaticLineVertsNoTex.emplace_back(zeus::CVector4f::ToClip(m_firstPos + dva, m_lastW), m_lastColor);
|
||||
g_StaticLineVertsNoTex.emplace_back(zeus::CVector4f::ToClip(m_firstPos - dva, m_lastW), m_lastColor);
|
||||
g_StaticLineVertsNoTex.emplace_back(zeus::CVector4f::ToClip(m_firstPos + dvb, m_lastW), m_lastColor);
|
||||
g_StaticLineVertsNoTex.emplace_back(zeus::CVector4f::ToClip(m_firstPos - dvb, m_lastW), m_lastColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -358,14 +311,14 @@ void CLineRenderer::Render(bool alphaWrite, const zeus::CColor& moduColor) {
|
|||
if (m_textured) {
|
||||
if (m_mode == EPrimitiveMode::Lines && (m_nextVert & 1)) {
|
||||
} else {
|
||||
g_StaticLineVertsTex.push_back({zeus::CVector4f::ToClip(m_lastPos + dv, m_lastW), m_lastColor, m_lastUV});
|
||||
g_StaticLineVertsTex.push_back({zeus::CVector4f::ToClip(m_lastPos - dv, m_lastW), m_lastColor, m_lastUV});
|
||||
g_StaticLineVertsTex.emplace_back(zeus::CVector4f::ToClip(m_lastPos + dv, m_lastW), m_lastColor, m_lastUV);
|
||||
g_StaticLineVertsTex.emplace_back(zeus::CVector4f::ToClip(m_lastPos - dv, m_lastW), m_lastColor, m_lastUV);
|
||||
}
|
||||
} else {
|
||||
if (m_mode == EPrimitiveMode::Lines && (m_nextVert & 1)) {
|
||||
} else {
|
||||
g_StaticLineVertsNoTex.push_back({zeus::CVector4f::ToClip(m_lastPos + dv, m_lastW), m_lastColor});
|
||||
g_StaticLineVertsNoTex.push_back({zeus::CVector4f::ToClip(m_lastPos - dv, m_lastW), m_lastColor});
|
||||
g_StaticLineVertsNoTex.emplace_back(zeus::CVector4f::ToClip(m_lastPos + dv, m_lastW), m_lastColor);
|
||||
g_StaticLineVertsNoTex.emplace_back(zeus::CVector4f::ToClip(m_lastPos - dv, m_lastW), m_lastColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -373,19 +326,16 @@ void CLineRenderer::Render(bool alphaWrite, const zeus::CColor& moduColor) {
|
|||
m_final = true;
|
||||
}
|
||||
|
||||
m_uniformBuf.access() = SDrawUniform{moduColor, CGraphics::g_Fog};
|
||||
m_uniformBuf.load(SDrawUniform{moduColor, CGraphics::g_Fog});
|
||||
if (m_textured) {
|
||||
if (!g_StaticLineVertsTex.empty()) {
|
||||
memmove(m_vertBufTex.access(), g_StaticLineVertsTex.data(), sizeof(SDrawVertTex) * g_StaticLineVertsTex.size());
|
||||
CGraphics::SetShaderDataBinding(m_shaderBind[alphaWrite]);
|
||||
CGraphics::DrawArray(0, g_StaticLineVertsTex.size());
|
||||
m_vertBuf.load<SDrawVertTex>(g_StaticLineVertsTex);
|
||||
m_shaderBind[alphaWrite].draw(0, g_StaticLineVertsTex.size());
|
||||
}
|
||||
} else {
|
||||
if (!g_StaticLineVertsNoTex.empty()) {
|
||||
memmove(m_vertBufNoTex.access(), g_StaticLineVertsNoTex.data(),
|
||||
sizeof(SDrawVertNoTex) * g_StaticLineVertsNoTex.size());
|
||||
CGraphics::SetShaderDataBinding(m_shaderBind[alphaWrite]);
|
||||
CGraphics::DrawArray(0, g_StaticLineVertsNoTex.size());
|
||||
m_vertBuf.load<SDrawVertNoTex>(g_StaticLineVertsNoTex);
|
||||
m_shaderBind[alphaWrite].draw(0, g_StaticLineVertsNoTex.size());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,15 +6,10 @@
|
|||
#include "Runtime/rstl.hpp"
|
||||
#include "Runtime/Graphics/CGraphics.hpp"
|
||||
|
||||
#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
||||
|
||||
#include <hecl/UniformBufferPool.hpp>
|
||||
#include <hecl/VertexBufferPool.hpp>
|
||||
|
||||
#include <zeus/CColor.hpp>
|
||||
#include <zeus/CVector2f.hpp>
|
||||
#include <zeus/CVector3f.hpp>
|
||||
#include <zeus/CVector4f.hpp>
|
||||
#include "zeus/CColor.hpp"
|
||||
#include "zeus/CVector2f.hpp"
|
||||
#include "zeus/CVector3f.hpp"
|
||||
#include "zeus/CVector4f.hpp"
|
||||
|
||||
namespace urde {
|
||||
|
||||
|
@ -22,19 +17,21 @@ class CLineRenderer {
|
|||
public:
|
||||
enum class EPrimitiveMode { Lines, LineStrip, LineLoop };
|
||||
|
||||
struct SDrawVertTex {
|
||||
zeus::CVector4f pos;
|
||||
zeus::CColor color;
|
||||
zeus::CVector2f uv;
|
||||
struct SDrawVertNoTex {
|
||||
hsh::float4 pos;
|
||||
hsh::float4 color;
|
||||
SDrawVertNoTex(hsh::float4 pos, hsh::float4 color) : pos(pos), color(color) {}
|
||||
};
|
||||
|
||||
struct SDrawVertNoTex {
|
||||
zeus::CVector4f pos;
|
||||
zeus::CColor color;
|
||||
struct SDrawVertTex {
|
||||
hsh::float4 pos;
|
||||
hsh::float4 color;
|
||||
hsh::float2 uv;
|
||||
SDrawVertTex(hsh::float4 pos, hsh::float4 color, hsh::float2 uv) : pos(pos), color(color), uv(uv) {}
|
||||
};
|
||||
|
||||
struct SDrawUniform {
|
||||
zeus::CColor moduColor;
|
||||
hsh::float4 moduColor;
|
||||
CGraphics::CFogState fog;
|
||||
};
|
||||
|
||||
|
@ -62,35 +59,19 @@ private:
|
|||
static rstl::reserved_vector<SDrawVertTex, 1024> g_StaticLineVertsTex;
|
||||
static rstl::reserved_vector<SDrawVertNoTex, 1024> g_StaticLineVertsNoTex;
|
||||
|
||||
static hecl::VertexBufferPool<SDrawVertTex> s_vertPoolTex;
|
||||
static hecl::VertexBufferPool<SDrawVertNoTex> s_vertPoolNoTex;
|
||||
static hecl::UniformBufferPool<SDrawUniform> s_uniformPool;
|
||||
|
||||
public:
|
||||
hecl::VertexBufferPool<SDrawVertTex>::Token m_vertBufTex;
|
||||
hecl::VertexBufferPool<SDrawVertNoTex>::Token m_vertBufNoTex;
|
||||
hecl::UniformBufferPool<SDrawUniform>::Token m_uniformBuf;
|
||||
std::array<boo::ObjToken<boo::IShaderDataBinding>, 2> m_shaderBind;
|
||||
hsh::dynamic_owner<hsh::vertex_buffer_typeless> m_vertBuf;
|
||||
hsh::dynamic_owner<hsh::uniform_buffer<SDrawUniform>> m_uniformBuf;
|
||||
hsh::binding m_shaderBind[2];
|
||||
|
||||
CLineRenderer(boo::IGraphicsDataFactory::Context& ctx, EPrimitiveMode mode, u32 maxVerts,
|
||||
const boo::ObjToken<boo::ITexture>& texture, bool additive, bool zTest = false, bool zGEqual = false);
|
||||
CLineRenderer(EPrimitiveMode mode, u32 maxVerts, const boo::ObjToken<boo::ITexture>& texture, bool additive,
|
||||
bool zTest = false, bool zGEqual = false);
|
||||
CLineRenderer(EPrimitiveMode mode, u32 maxVerts, hsh::texture2d texture, bool additive,
|
||||
hsh::Compare zComp = hsh::Always);
|
||||
CLineRenderer(CLineRenderer&&) = default;
|
||||
|
||||
void Reset();
|
||||
void AddVertex(const zeus::CVector3f& position, const zeus::CColor& color, float width,
|
||||
const zeus::CVector2f& uv = zeus::skZero2f);
|
||||
void Render(bool alphaWrite = false, const zeus::CColor& moduColor = zeus::skWhite);
|
||||
|
||||
static void UpdateBuffers() {
|
||||
s_vertPoolTex.updateBuffers();
|
||||
s_vertPoolNoTex.updateBuffers();
|
||||
s_uniformPool.updateBuffers();
|
||||
}
|
||||
|
||||
static void Initialize();
|
||||
static void Shutdown();
|
||||
};
|
||||
|
||||
} // namespace urde
|
||||
|
|
|
@ -47,3 +47,12 @@ set(GRAPHICS_SOURCES
|
|||
Shaders/CEnvFxShaders.hpp Shaders/CEnvFxShaders.cpp)
|
||||
|
||||
runtime_add_list(Graphics GRAPHICS_SOURCES)
|
||||
|
||||
runtime_add_hsh(Graphics
|
||||
CMoviePlayer.cpp
|
||||
Shaders/CLineRendererShaders.cpp
|
||||
Shaders/CColoredQuadFilter.cpp
|
||||
Shaders/CTexturedQuadFilter.cpp
|
||||
Shaders/CCameraBlurFilter.cpp
|
||||
Shaders/CFogVolumePlaneShader.cpp
|
||||
)
|
||||
|
|
|
@ -27,7 +27,6 @@ class CMetroidModelInstance {
|
|||
std::vector<CBooSurface> m_surfaces;
|
||||
std::unique_ptr<CBooModel> m_instance;
|
||||
hecl::HMDLMeta m_hmdlMeta;
|
||||
std::unordered_map<int, CModelShaders::ShaderPipelines> m_shaders;
|
||||
|
||||
public:
|
||||
CMetroidModelInstance() = default;
|
||||
|
@ -39,7 +38,6 @@ public:
|
|||
m_surfaces.clear();
|
||||
m_instance.reset();
|
||||
m_hmdlMeta = {};
|
||||
m_shaders.clear();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -12,10 +12,9 @@
|
|||
#include "Runtime/RetroTypes.hpp"
|
||||
#include "Shaders/CModelShaders.hpp"
|
||||
|
||||
#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
||||
#include <hecl/HMDLMeta.hpp>
|
||||
#include <zeus/CAABox.hpp>
|
||||
#include <zeus/CColor.hpp>
|
||||
#include "hecl/HMDLMeta.hpp"
|
||||
#include "zeus/CAABox.hpp"
|
||||
#include "zeus/CColor.hpp"
|
||||
|
||||
namespace urde {
|
||||
class CLight;
|
||||
|
@ -28,6 +27,7 @@ class IObjectStore;
|
|||
struct CModelFlags {
|
||||
u8 x0_blendMode = 0; /* 2: add color, >6: additive, >4: blend, else opaque */
|
||||
u8 x1_matSetIdx = 0;
|
||||
EPostType m_postType = EPostType::Normal;
|
||||
EExtendedShader m_extendedShader = EExtendedShader::Lighting;
|
||||
bool m_noCull = false;
|
||||
bool m_noZWrite = false;
|
||||
|
@ -80,7 +80,7 @@ struct CBooSurface {
|
|||
using MaterialSet = DataSpec::DNAMP1::HMDLMaterialSet;
|
||||
|
||||
struct GeometryUniformLayout {
|
||||
mutable std::vector<boo::ObjToken<boo::IGraphicsBufferD>> m_sharedBuffer;
|
||||
mutable std::vector<hsh::dynamic_owner<hsh::uniform_buffer_typeless>> m_sharedBuffer;
|
||||
size_t m_geomBufferSize = 0;
|
||||
size_t m_skinBankCount = 0;
|
||||
size_t m_weightVecCount = 0;
|
||||
|
@ -93,28 +93,33 @@ struct GeometryUniformLayout {
|
|||
|
||||
GeometryUniformLayout(const CModel* model, const MaterialSet* matSet);
|
||||
void Update(const CModelFlags& flags, const CSkinRules* cskr, const CPoseAsTransforms* pose,
|
||||
const MaterialSet* matSet, const boo::ObjToken<boo::IGraphicsBufferD>& buf,
|
||||
const MaterialSet* matSet, hsh::dynamic_owner<hsh::uniform_buffer_typeless>& buf,
|
||||
const CBooModel* parent) const;
|
||||
|
||||
void ReserveSharedBuffers(boo::IGraphicsDataFactory::Context& ctx, int size);
|
||||
boo::ObjToken<boo::IGraphicsBufferD> GetSharedBuffer(int idx) const;
|
||||
hsh::dynamic_owner<hsh::uniform_buffer_typeless> AllocateVertUniformBuffer() const;
|
||||
void ReserveSharedBuffers(size_t size);
|
||||
hsh::uniform_buffer_typeless GetSharedBuffer(size_t idx) const;
|
||||
};
|
||||
|
||||
struct SShader {
|
||||
std::unordered_map<CAssetId, TCachedToken<CTexture>> x0_textures;
|
||||
std::unordered_map<int, CModelShaders::ShaderPipelines> m_shaders;
|
||||
MaterialSet m_matSet;
|
||||
std::optional<GeometryUniformLayout> m_geomLayout;
|
||||
int m_matSetIdx;
|
||||
explicit SShader(int idx) : m_matSetIdx(idx) {
|
||||
x0_textures.clear();
|
||||
m_shaders.clear();
|
||||
}
|
||||
void InitializeLayout(const CModel* model) { m_geomLayout.emplace(model, &m_matSet); }
|
||||
void UnlockTextures();
|
||||
CModelShaders::ShaderPipelines BuildShader(const hecl::HMDLMeta& meta, const MaterialSet::Material& mat);
|
||||
void BuildShaders(const hecl::HMDLMeta& meta, std::unordered_map<int, CModelShaders::ShaderPipelines>& shaders);
|
||||
void BuildShaders(const hecl::HMDLMeta& meta) { BuildShaders(meta, m_shaders); }
|
||||
};
|
||||
|
||||
struct VertexFormat {
|
||||
uint8_t NSkinSlots;
|
||||
uint8_t NCol;
|
||||
uint8_t NUv;
|
||||
uint8_t NWeight;
|
||||
explicit VertexFormat(const hecl::HMDLMeta& meta)
|
||||
: NSkinSlots(meta.weightCount * 4), NCol(meta.colorCount), NUv(meta.uvCount), NWeight(meta.weightCount) {}
|
||||
};
|
||||
|
||||
class CBooModel {
|
||||
|
@ -124,6 +129,7 @@ class CBooModel {
|
|||
friend class CModel;
|
||||
friend class CSkinnedModel;
|
||||
friend struct GeometryUniformLayout;
|
||||
friend class CModelShaders;
|
||||
|
||||
public:
|
||||
enum class ESurfaceSelection { UnsortedOnly, SortedOnly, All };
|
||||
|
@ -137,8 +143,8 @@ private:
|
|||
std::vector<CBooSurface>* x0_surfaces;
|
||||
const MaterialSet* x4_matSet;
|
||||
const GeometryUniformLayout* m_geomLayout;
|
||||
VertexFormat m_vtxFmt;
|
||||
int m_matSetIdx = -1;
|
||||
const std::unordered_map<int, CModelShaders::ShaderPipelines>* m_pipelines;
|
||||
std::unordered_map<CAssetId, TCachedToken<CTexture>> x1c_textures;
|
||||
zeus::CAABox x20_aabb;
|
||||
CBooSurface* x38_firstUnsortedSurface = nullptr;
|
||||
|
@ -159,22 +165,22 @@ private:
|
|||
/* urde addition: boo! */
|
||||
size_t m_uniformDataSize = 0;
|
||||
struct ModelInstance {
|
||||
boo::ObjToken<boo::IGraphicsBufferD> m_geomUniformBuffer;
|
||||
boo::ObjToken<boo::IGraphicsBufferD> m_uniformBuffer;
|
||||
std::vector<std::vector<boo::ObjToken<boo::IShaderDataBinding>>> m_shaderDataBindings;
|
||||
boo::ObjToken<boo::IGraphicsBufferD> m_dynamicVbo;
|
||||
hsh::dynamic_owner<hsh::uniform_buffer_typeless> m_geomUniformBuffer;
|
||||
hsh::dynamic_owner<hsh::uniform_buffer_typeless> m_uniformBuffer;
|
||||
std::vector<std::vector<hsh::binding>> m_shaderDataBindings;
|
||||
hsh::dynamic_owner<hsh::vertex_buffer_typeless> m_dynamicVbo;
|
||||
|
||||
boo::ObjToken<boo::IGraphicsBuffer> GetBooVBO(const CBooModel& model, boo::IGraphicsDataFactory::Context& ctx);
|
||||
hsh::vertex_buffer_typeless GetBooVBO(const CBooModel& model);
|
||||
};
|
||||
std::vector<ModelInstance> m_instances;
|
||||
ModelInstance m_ballShadowInstance;
|
||||
|
||||
boo::ObjToken<boo::IGraphicsBufferS> m_staticVbo;
|
||||
boo::ObjToken<boo::IGraphicsBufferS> m_staticIbo;
|
||||
hsh::vertex_buffer_typeless m_staticVbo;
|
||||
hsh::index_buffer<u32> m_staticIbo;
|
||||
|
||||
boo::ObjToken<boo::ITexture> m_lastDrawnShadowMap;
|
||||
boo::ObjToken<boo::ITexture> m_lastDrawnOneTexture;
|
||||
boo::ObjToken<boo::ITextureCubeR> m_lastDrawnReflectionCube;
|
||||
hsh::texture2d m_lastDrawnShadowMap;
|
||||
hsh::texture2d m_lastDrawnOneTexture;
|
||||
hsh::texturecube m_lastDrawnReflectionCube;
|
||||
|
||||
ModelInstance* PushNewModelInstance(int sharedLayoutBuf = -1);
|
||||
void DrawAlphaSurfaces(const CModelFlags& flags) const;
|
||||
|
@ -196,7 +202,8 @@ private:
|
|||
public:
|
||||
~CBooModel();
|
||||
CBooModel(TToken<CModel>& token, CModel* parent, std::vector<CBooSurface>* surfaces, SShader& shader,
|
||||
const boo::ObjToken<boo::IGraphicsBufferS>& vbo, const boo::ObjToken<boo::IGraphicsBufferS>& ibo,
|
||||
hsh::vertex_buffer_typeless vbo,
|
||||
hsh::index_buffer<u32> ibo,
|
||||
const zeus::CAABox& aabb, u8 renderMask, int numInsts);
|
||||
|
||||
static void MakeTexturesFromMats(const MaterialSet& matSet,
|
||||
|
@ -209,14 +216,13 @@ public:
|
|||
void SetAmbientColor(const zeus::CColor& color) { m_lightingData.ambient = color; }
|
||||
void DisableAllLights();
|
||||
void RemapMaterialData(SShader& shader);
|
||||
void RemapMaterialData(SShader& shader, const std::unordered_map<int, CModelShaders::ShaderPipelines>& pipelines);
|
||||
bool TryLockTextures();
|
||||
void UnlockTextures();
|
||||
void SyncLoadTextures();
|
||||
void Touch(int shaderIdx);
|
||||
void VerifyCurrentShader(int shaderIdx);
|
||||
boo::ObjToken<boo::IGraphicsBufferD> UpdateUniformData(const CModelFlags& flags, const CSkinRules* cskr,
|
||||
const CPoseAsTransforms* pose, int sharedLayoutBuf = -1);
|
||||
hsh::dynamic_owner<hsh::vertex_buffer_typeless>* UpdateUniformData(const CModelFlags& flags, const CSkinRules* cskr,
|
||||
const CPoseAsTransforms* pose, int sharedLayoutBuf = -1);
|
||||
void DrawAlpha(const CModelFlags& flags, const CSkinRules* cskr, const CPoseAsTransforms* pose);
|
||||
void DrawNormal(const CModelFlags& flags, const CSkinRules* cskr, const CPoseAsTransforms* pose);
|
||||
void Draw(const CModelFlags& flags, const CSkinRules* cskr, const CPoseAsTransforms* pose);
|
||||
|
@ -240,16 +246,16 @@ public:
|
|||
static void EnsureViewDepStateCached(const CBooModel& model, const CBooSurface* surf, zeus::CMatrix4f* mtxsOut,
|
||||
float& alphaOut);
|
||||
|
||||
static boo::ObjToken<boo::ITexture> g_shadowMap;
|
||||
static hsh::texture2d g_shadowMap;
|
||||
static zeus::CTransform g_shadowTexXf;
|
||||
static void EnableShadowMaps(const boo::ObjToken<boo::ITexture>& map, const zeus::CTransform& texXf);
|
||||
static void EnableShadowMaps(hsh::texture2d map, const zeus::CTransform& texXf);
|
||||
static void DisableShadowMaps();
|
||||
|
||||
static boo::ObjToken<boo::ITexture> g_disintegrateTexture;
|
||||
static void SetDisintegrateTexture(const boo::ObjToken<boo::ITexture>& map) { g_disintegrateTexture = map; }
|
||||
static hsh::texture2d g_disintegrateTexture;
|
||||
static void SetDisintegrateTexture(hsh::texture2d map) { g_disintegrateTexture = map; }
|
||||
|
||||
static boo::ObjToken<boo::ITextureCubeR> g_reflectionCube;
|
||||
static void SetReflectionCube(const boo::ObjToken<boo::ITextureCubeR>& map) { g_reflectionCube = map; }
|
||||
static hsh::texturecube g_reflectionCube;
|
||||
static void SetReflectionCube(hsh::texturecube map) { g_reflectionCube = map; }
|
||||
|
||||
static void SetDummyTextures(bool b) { g_DummyTextures = b; }
|
||||
static void SetRenderModelBlack(bool b) { g_RenderModelBlack = b; }
|
||||
|
@ -274,11 +280,11 @@ class CModel {
|
|||
// CModel* x34_prev = nullptr;
|
||||
int x38_lastFrame;
|
||||
|
||||
/* urde addition: boo! */
|
||||
boo::ObjToken<boo::IGraphicsBufferS> m_staticVbo;
|
||||
/* urde addition: boo2! */
|
||||
hsh::owner<hsh::vertex_buffer_typeless> m_staticVbo;
|
||||
hecl::HMDLMeta m_hmdlMeta;
|
||||
std::unique_ptr<uint8_t[]> m_dynamicVertexData;
|
||||
boo::ObjToken<boo::IGraphicsBufferS> m_ibo;
|
||||
hsh::owner<hsh::index_buffer<u32>> m_ibo;
|
||||
|
||||
public:
|
||||
using MaterialSet = DataSpec::DNAMP1::HMDLMaterialSet;
|
||||
|
@ -301,12 +307,15 @@ public:
|
|||
zeus::CVector3f GetPoolVertex(size_t idx) const;
|
||||
size_t GetPoolNormalOffset(size_t idx) const;
|
||||
zeus::CVector3f GetPoolNormal(size_t idx) const;
|
||||
void ApplyVerticesCPU(const boo::ObjToken<boo::IGraphicsBufferD>& vertBuf,
|
||||
void ApplyVerticesCPU(hsh::owner<hsh::vertex_buffer_typeless>& vertBuf,
|
||||
const std::vector<std::pair<zeus::CVector3f, zeus::CVector3f>>& vn) const;
|
||||
void RestoreVerticesCPU(const boo::ObjToken<boo::IGraphicsBufferD>& vertBuf) const;
|
||||
void RestoreVerticesCPU(hsh::owner<hsh::vertex_buffer_typeless>& vertBuf) const;
|
||||
|
||||
void _WarmupShaders();
|
||||
static void WarmupShaders(const SObjectTag& cmdlTag);
|
||||
|
||||
const uint8_t* GetDynamicVertexData() const { return m_dynamicVertexData.get() }
|
||||
const hecl::HMDLMeta& GetHMDLMeta() const { return m_hmdlMeta; }
|
||||
};
|
||||
|
||||
CFactoryFnReturn FModelFactory(const urde::SObjectTag& tag, std::unique_ptr<u8[]>&& in, u32 len,
|
||||
|
|
|
@ -151,7 +151,7 @@ zeus::CTransform CBooModel::g_shadowTexXf;
|
|||
boo::ObjToken<boo::ITexture> CBooModel::g_disintegrateTexture;
|
||||
boo::ObjToken<boo::ITextureCubeR> CBooModel::g_reflectionCube;
|
||||
|
||||
void CBooModel::EnableShadowMaps(const boo::ObjToken<boo::ITexture>& map, const zeus::CTransform& texXf) {
|
||||
void CBooModel::EnableShadowMaps(hsh::texture2d map, const zeus::CTransform& texXf) {
|
||||
g_shadowMap = map;
|
||||
g_shadowTexXf = texXf;
|
||||
}
|
||||
|
@ -167,19 +167,18 @@ CBooModel::~CBooModel() {
|
|||
}
|
||||
|
||||
CBooModel::CBooModel(TToken<CModel>& token, CModel* parent, std::vector<CBooSurface>* surfaces, SShader& shader,
|
||||
const boo::ObjToken<boo::IGraphicsBufferS>& vbo, const boo::ObjToken<boo::IGraphicsBufferS>& ibo,
|
||||
const zeus::CAABox& aabb, u8 renderMask, int numInsts)
|
||||
hsh::vertex_buffer_typeless vbo, hsh::index_buffer<u32> ibo, const zeus::CAABox& aabb,
|
||||
u8 renderMask, int numInsts)
|
||||
: m_modelTok(token)
|
||||
, m_model(parent)
|
||||
, x0_surfaces(surfaces)
|
||||
, x4_matSet(&shader.m_matSet)
|
||||
, m_geomLayout(&*shader.m_geomLayout)
|
||||
, m_matSetIdx(shader.m_matSetIdx)
|
||||
, m_pipelines(&shader.m_shaders)
|
||||
, x1c_textures(shader.x0_textures)
|
||||
, x20_aabb(aabb)
|
||||
, x40_24_texturesLoaded(false)
|
||||
, x40_25_modelVisible(0)
|
||||
, x40_25_modelVisible(false)
|
||||
, x41_mask(renderMask)
|
||||
, m_staticVbo(vbo)
|
||||
, m_staticIbo(ibo) {
|
||||
|
@ -211,15 +210,56 @@ CBooModel::CBooModel(TToken<CModel>& token, CModel* parent, std::vector<CBooSurf
|
|||
PushNewModelInstance();
|
||||
}
|
||||
|
||||
boo::ObjToken<boo::IGraphicsBuffer> CBooModel::ModelInstance::GetBooVBO(const CBooModel& model,
|
||||
boo::IGraphicsDataFactory::Context& ctx) {
|
||||
hsh::vertex_buffer_typeless CBooModel::ModelInstance::GetBooVBO(const CBooModel& model) {
|
||||
if (model.m_staticVbo)
|
||||
return model.m_staticVbo.get();
|
||||
return model.m_staticVbo;
|
||||
if (!m_dynamicVbo && model.m_model) {
|
||||
const CModel& parent = *model.m_model;
|
||||
m_dynamicVbo =
|
||||
ctx.newDynamicBuffer(boo::BufferUse::Vertex, parent.m_hmdlMeta.vertStride, parent.m_hmdlMeta.vertCount);
|
||||
m_dynamicVbo->load(parent.m_dynamicVertexData.get(), parent.m_hmdlMeta.vertStride * parent.m_hmdlMeta.vertCount);
|
||||
auto CreateVBO = [this, &parent]<uint32_t NUVs, uint32_t NWeights>() {
|
||||
using VertData = CModelShaders::VertData<0, NUVs, NWeights>;
|
||||
assert(sizeof(VertData) == parent.GetHMDLMeta().vertStride && "Vert data stride mismatch");
|
||||
m_dynamicVbo = hsh::create_dynamic_vertex_buffer<VertData>(parent.GetHMDLMeta().vertCount);
|
||||
};
|
||||
#define VERT_DATA(uvs) \
|
||||
switch (parent.GetHMDLMeta().weightCount) { \
|
||||
case 0: \
|
||||
CreateVBO.operator()<uvs, 0>(); \
|
||||
break; \
|
||||
case 1: \
|
||||
CreateVBO.operator()<uvs, 1>(); \
|
||||
break; \
|
||||
case 2: \
|
||||
CreateVBO.operator()<uvs, 2>(); \
|
||||
break; \
|
||||
case 3: \
|
||||
CreateVBO.operator()<uvs, 3>(); \
|
||||
break; \
|
||||
case 4: \
|
||||
CreateVBO.operator()<uvs, 4>(); \
|
||||
break; \
|
||||
default: \
|
||||
assert(false && "Unhandled weight count"); \
|
||||
break; \
|
||||
} \
|
||||
break;
|
||||
switch (parent.GetHMDLMeta().uvCount) {
|
||||
case 0:
|
||||
VERT_DATA(0)
|
||||
case 1:
|
||||
VERT_DATA(1)
|
||||
case 2:
|
||||
VERT_DATA(2)
|
||||
case 3:
|
||||
VERT_DATA(3)
|
||||
case 4:
|
||||
VERT_DATA(4)
|
||||
#undef VERT_DATA
|
||||
default:
|
||||
assert(false && "Unhandled UV count");
|
||||
break;
|
||||
}
|
||||
m_dynamicVbo.load<uint8_t>(
|
||||
{parent.GetDynamicVertexData(), parent.GetHMDLMeta().vertStride * parent.GetHMDLMeta().vertCount});
|
||||
}
|
||||
return m_dynamicVbo.get();
|
||||
}
|
||||
|
@ -273,142 +313,154 @@ CBooModel::ModelInstance* CBooModel::PushNewModelInstance(int sharedLayoutBuf) {
|
|||
|
||||
ModelInstance& newInst = m_instances.emplace_back();
|
||||
|
||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
||||
/* Build geometry uniform buffer if shared not available */
|
||||
boo::ObjToken<boo::IGraphicsBufferD> geomUniformBuf;
|
||||
if (sharedLayoutBuf >= 0) {
|
||||
geomUniformBuf = m_geomLayout->GetSharedBuffer(sharedLayoutBuf);
|
||||
} else {
|
||||
geomUniformBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, m_geomLayout->m_geomBufferSize, 1);
|
||||
newInst.m_geomUniformBuffer = geomUniformBuf;
|
||||
/* Build geometry uniform buffer if shared not available */
|
||||
hsh::uniform_buffer_typeless geomUniformBuf;
|
||||
if (sharedLayoutBuf >= 0) {
|
||||
geomUniformBuf = m_geomLayout->GetSharedBuffer(sharedLayoutBuf);
|
||||
} else {
|
||||
auto CreateUBO = [&]<uint32_t NSkinSlots>() {
|
||||
newInst.m_geomUniformBuffer = hsh::create_dynamic_uniform_buffer<CModelShaders::VertUniform<NSkinSlots>>();
|
||||
geomUniformBuf = newInst.m_geomUniformBuffer;
|
||||
};
|
||||
switch (m_vtxFmt.NSkinSlots) {
|
||||
#define VERT_UNIFORM(nskins) \
|
||||
case nskins: \
|
||||
CreateUBO.operator()<nskins>(); \
|
||||
break;
|
||||
VERT_UNIFORM(0)
|
||||
VERT_UNIFORM(4)
|
||||
VERT_UNIFORM(8)
|
||||
VERT_UNIFORM(12)
|
||||
VERT_UNIFORM(16)
|
||||
#undef VERT_UNIFORM
|
||||
default:
|
||||
assert(false && "Unhandled skin slot count");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Lighting and reflection uniforms */
|
||||
size_t uniBufSize = 0;
|
||||
/* Lighting and reflection uniforms */
|
||||
size_t uniBufSize = 0;
|
||||
|
||||
/* Lighting uniform */
|
||||
size_t lightOff = 0;
|
||||
size_t lightSz = 0;
|
||||
{
|
||||
size_t thisSz = ROUND_UP_256(sizeof(CModelShaders::LightingUniform));
|
||||
lightOff = uniBufSize;
|
||||
lightSz = thisSz;
|
||||
uniBufSize += thisSz;
|
||||
}
|
||||
/* Lighting uniform */
|
||||
size_t lightOff = 0;
|
||||
size_t lightSz = 0;
|
||||
{
|
||||
size_t thisSz = ROUND_UP_256(sizeof(CModelShaders::LightingUniform));
|
||||
lightOff = uniBufSize;
|
||||
lightSz = thisSz;
|
||||
uniBufSize += thisSz;
|
||||
}
|
||||
|
||||
/* Surface reflection texmatrix uniform with first identity slot */
|
||||
size_t reflectOff = uniBufSize;
|
||||
uniBufSize += 256;
|
||||
for (const CBooSurface& surf : *x0_surfaces) {
|
||||
const MaterialSet::Material& mat = x4_matSet->materials.at(surf.m_data.matIdx);
|
||||
if (mat.flags.samusReflection() || mat.flags.samusReflectionSurfaceEye())
|
||||
uniBufSize += 256;
|
||||
}
|
||||
/* Surface reflection texmatrix uniform with first identity slot */
|
||||
size_t reflectOff = uniBufSize;
|
||||
uniBufSize += 256;
|
||||
for (const CBooSurface& surf : *x0_surfaces) {
|
||||
const MaterialSet::Material& mat = x4_matSet->materials.at(surf.m_data.matIdx);
|
||||
if (mat.flags.samusReflection() || mat.flags.samusReflectionSurfaceEye())
|
||||
uniBufSize += 256;
|
||||
}
|
||||
|
||||
/* Allocate resident buffer */
|
||||
m_uniformDataSize = uniBufSize;
|
||||
newInst.m_uniformBuffer = ctx.newDynamicBuffer(boo::BufferUse::Uniform, uniBufSize, 1);
|
||||
/* Allocate resident buffer */
|
||||
m_uniformDataSize = uniBufSize;
|
||||
newInst.m_uniformBuffer = ctx.newDynamicBuffer(boo::BufferUse::Uniform, uniBufSize, 1);
|
||||
|
||||
boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {geomUniformBuf.get(), geomUniformBuf.get(),
|
||||
newInst.m_uniformBuffer.get(), newInst.m_uniformBuffer.get()};
|
||||
boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {geomUniformBuf.get(), geomUniformBuf.get(),
|
||||
newInst.m_uniformBuffer.get(), newInst.m_uniformBuffer.get()};
|
||||
|
||||
/* Binding for each surface */
|
||||
newInst.m_shaderDataBindings.reserve(x0_surfaces->size());
|
||||
/* Binding for each surface */
|
||||
newInst.m_shaderDataBindings.reserve(x0_surfaces->size());
|
||||
|
||||
size_t thisOffs[4];
|
||||
size_t thisSizes[4];
|
||||
size_t thisOffs[4];
|
||||
size_t thisSizes[4];
|
||||
|
||||
static const boo::PipelineStage stages[4] = {boo::PipelineStage::Vertex, boo::PipelineStage::Vertex,
|
||||
boo::PipelineStage::Fragment, boo::PipelineStage::Vertex};
|
||||
static const boo::PipelineStage stages[4] = {boo::PipelineStage::Vertex, boo::PipelineStage::Vertex,
|
||||
boo::PipelineStage::Fragment, boo::PipelineStage::Vertex};
|
||||
|
||||
/* Enumerate surfaces and build data bindings */
|
||||
size_t curReflect = reflectOff + 256;
|
||||
for (const CBooSurface& surf : *x0_surfaces) {
|
||||
const MaterialSet::Material& mat = x4_matSet->materials.at(surf.m_data.matIdx);
|
||||
/* Enumerate surfaces and build data bindings */
|
||||
size_t curReflect = reflectOff + 256;
|
||||
for (const CBooSurface& surf : *x0_surfaces) {
|
||||
const MaterialSet::Material& mat = x4_matSet->materials.at(surf.m_data.matIdx);
|
||||
|
||||
boo::ObjToken<boo::ITexture> texs[12] = {g_Renderer->m_clearTexture.get(), g_Renderer->m_clearTexture.get(),
|
||||
g_Renderer->m_clearTexture.get(), g_Renderer->m_clearTexture.get(),
|
||||
g_Renderer->m_clearTexture.get(), g_Renderer->m_clearTexture.get(),
|
||||
g_Renderer->m_clearTexture.get(), g_Renderer->m_clearTexture.get(),
|
||||
g_Renderer->x220_sphereRamp.get(), g_Renderer->x220_sphereRamp.get(),
|
||||
g_Renderer->x220_sphereRamp.get(), g_Renderer->x220_sphereRamp.get()};
|
||||
if (!g_DummyTextures) {
|
||||
for (const auto& ch : mat.chunks) {
|
||||
if (auto pass = ch.get_if<MaterialSet::Material::PASS>()) {
|
||||
auto search = x1c_textures.find(pass->texId.toUint32());
|
||||
boo::ObjToken<boo::ITexture> btex;
|
||||
if (search != x1c_textures.cend() && (btex = search->second.GetObj()->GetBooTexture()))
|
||||
texs[MaterialSet::Material::TexMapIdx(pass->type)] = btex;
|
||||
} else if (auto pass = ch.get_if<MaterialSet::Material::CLR>()) {
|
||||
boo::ObjToken<boo::ITexture> btex = g_Renderer->GetColorTexture(zeus::CColor(pass->color));
|
||||
boo::ObjToken<boo::ITexture> texs[12] = {
|
||||
g_Renderer->m_clearTexture.get(), g_Renderer->m_clearTexture.get(), g_Renderer->m_clearTexture.get(),
|
||||
g_Renderer->m_clearTexture.get(), g_Renderer->m_clearTexture.get(), g_Renderer->m_clearTexture.get(),
|
||||
g_Renderer->m_clearTexture.get(), g_Renderer->m_clearTexture.get(), g_Renderer->x220_sphereRamp.get(),
|
||||
g_Renderer->x220_sphereRamp.get(), g_Renderer->x220_sphereRamp.get(), g_Renderer->x220_sphereRamp.get()};
|
||||
if (!g_DummyTextures) {
|
||||
for (const auto& ch : mat.chunks) {
|
||||
if (auto pass = ch.get_if<MaterialSet::Material::PASS>()) {
|
||||
auto search = x1c_textures.find(pass->texId.toUint32());
|
||||
boo::ObjToken<boo::ITexture> btex;
|
||||
if (search != x1c_textures.cend() && (btex = search->second.GetObj()->GetBooTexture()))
|
||||
texs[MaterialSet::Material::TexMapIdx(pass->type)] = btex;
|
||||
}
|
||||
} else if (auto pass = ch.get_if<MaterialSet::Material::CLR>()) {
|
||||
boo::ObjToken<boo::ITexture> btex = g_Renderer->GetColorTexture(zeus::CColor(pass->color));
|
||||
texs[MaterialSet::Material::TexMapIdx(pass->type)] = btex;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_geomLayout->m_skinBankCount) {
|
||||
thisOffs[0] = m_geomLayout->m_skinOffs[surf.m_data.skinMtxBankIdx];
|
||||
thisSizes[0] = m_geomLayout->m_skinSizes[surf.m_data.skinMtxBankIdx];
|
||||
} else {
|
||||
thisOffs[0] = 0;
|
||||
thisSizes[0] = 256;
|
||||
}
|
||||
|
||||
thisOffs[1] = m_geomLayout->m_uvOffs[surf.m_data.matIdx];
|
||||
thisSizes[1] = m_geomLayout->m_uvSizes[surf.m_data.matIdx];
|
||||
|
||||
thisOffs[2] = lightOff;
|
||||
thisSizes[2] = lightSz;
|
||||
|
||||
bool useReflection = mat.flags.samusReflection() || mat.flags.samusReflectionSurfaceEye();
|
||||
if (useReflection) {
|
||||
if (g_Renderer->x14c_reflectionTex)
|
||||
texs[11] = g_Renderer->x14c_reflectionTex.get();
|
||||
thisOffs[3] = curReflect;
|
||||
curReflect += 256;
|
||||
} else {
|
||||
thisOffs[3] = reflectOff;
|
||||
}
|
||||
thisSizes[3] = 256;
|
||||
|
||||
const CModelShaders::ShaderPipelines& pipelines = m_pipelines->at(surf.m_data.matIdx);
|
||||
|
||||
std::vector<boo::ObjToken<boo::IShaderDataBinding>>& extendeds = newInst.m_shaderDataBindings.emplace_back();
|
||||
extendeds.reserve(pipelines->size());
|
||||
|
||||
EExtendedShader idx{};
|
||||
for (const auto& pipeline : *pipelines) {
|
||||
if (idx == EExtendedShader::Thermal) {
|
||||
texs[8] = g_Renderer->x220_sphereRamp.get();
|
||||
} else if (idx == EExtendedShader::MorphBallShadow) {
|
||||
texs[8] = g_Renderer->m_ballShadowId.get();
|
||||
texs[9] = g_Renderer->x220_sphereRamp.get();
|
||||
texs[10] = g_Renderer->m_ballFade.get();
|
||||
} else if (idx == EExtendedShader::WorldShadow || idx == EExtendedShader::LightingCubeReflectionWorldShadow) {
|
||||
if (g_shadowMap)
|
||||
texs[8] = g_shadowMap;
|
||||
else
|
||||
texs[8] = g_Renderer->x220_sphereRamp.get();
|
||||
} else if (idx == EExtendedShader::Disintegrate) {
|
||||
if (g_disintegrateTexture)
|
||||
texs[8] = g_disintegrateTexture;
|
||||
else
|
||||
texs[8] = g_Renderer->x220_sphereRamp.get();
|
||||
} else if (hecl::com_cubemaps->toBoolean() && (idx == EExtendedShader::LightingCubeReflection ||
|
||||
idx == EExtendedShader::LightingCubeReflectionWorldShadow)) {
|
||||
if (m_lastDrawnReflectionCube)
|
||||
texs[11] = m_lastDrawnReflectionCube.get();
|
||||
else
|
||||
texs[11] = g_Renderer->x220_sphereRamp.get();
|
||||
}
|
||||
extendeds.push_back(ctx.newShaderDataBinding(pipeline, newInst.GetBooVBO(*this, ctx), nullptr,
|
||||
m_staticIbo.get(), 4, bufs, stages, thisOffs, thisSizes, 12, texs,
|
||||
nullptr, nullptr));
|
||||
idx = EExtendedShader(size_t(idx) + 1);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} BooTrace);
|
||||
|
||||
if (m_geomLayout->m_skinBankCount) {
|
||||
thisOffs[0] = m_geomLayout->m_skinOffs[surf.m_data.skinMtxBankIdx];
|
||||
thisSizes[0] = m_geomLayout->m_skinSizes[surf.m_data.skinMtxBankIdx];
|
||||
} else {
|
||||
thisOffs[0] = 0;
|
||||
thisSizes[0] = 256;
|
||||
}
|
||||
|
||||
thisOffs[1] = m_geomLayout->m_uvOffs[surf.m_data.matIdx];
|
||||
thisSizes[1] = m_geomLayout->m_uvSizes[surf.m_data.matIdx];
|
||||
|
||||
thisOffs[2] = lightOff;
|
||||
thisSizes[2] = lightSz;
|
||||
|
||||
bool useReflection = mat.flags.samusReflection() || mat.flags.samusReflectionSurfaceEye();
|
||||
if (useReflection) {
|
||||
if (g_Renderer->x14c_reflectionTex)
|
||||
texs[11] = g_Renderer->x14c_reflectionTex.get();
|
||||
thisOffs[3] = curReflect;
|
||||
curReflect += 256;
|
||||
} else {
|
||||
thisOffs[3] = reflectOff;
|
||||
}
|
||||
thisSizes[3] = 256;
|
||||
|
||||
const CModelShaders::ShaderPipelines& pipelines = m_pipelines->at(surf.m_data.matIdx);
|
||||
|
||||
std::vector<boo::ObjToken<boo::IShaderDataBinding>>& extendeds = newInst.m_shaderDataBindings.emplace_back();
|
||||
extendeds.reserve(pipelines->size());
|
||||
|
||||
EExtendedShader idx{};
|
||||
for (const auto& pipeline : *pipelines) {
|
||||
if (idx == EExtendedShader::Thermal) {
|
||||
texs[8] = g_Renderer->x220_sphereRamp.get();
|
||||
} else if (idx == EExtendedShader::MorphBallShadow) {
|
||||
texs[8] = g_Renderer->m_ballShadowId.get();
|
||||
texs[9] = g_Renderer->x220_sphereRamp.get();
|
||||
texs[10] = g_Renderer->m_ballFade.get();
|
||||
} else if (idx == EExtendedShader::WorldShadow || idx == EExtendedShader::LightingCubeReflectionWorldShadow) {
|
||||
if (g_shadowMap)
|
||||
texs[8] = g_shadowMap;
|
||||
else
|
||||
texs[8] = g_Renderer->x220_sphereRamp.get();
|
||||
} else if (idx == EExtendedShader::Disintegrate) {
|
||||
if (g_disintegrateTexture)
|
||||
texs[8] = g_disintegrateTexture;
|
||||
else
|
||||
texs[8] = g_Renderer->x220_sphereRamp.get();
|
||||
} else if (hecl::com_cubemaps->toBoolean() && (idx == EExtendedShader::LightingCubeReflection ||
|
||||
idx == EExtendedShader::LightingCubeReflectionWorldShadow)) {
|
||||
if (m_lastDrawnReflectionCube)
|
||||
texs[11] = m_lastDrawnReflectionCube.get();
|
||||
else
|
||||
texs[11] = g_Renderer->x220_sphereRamp.get();
|
||||
}
|
||||
extendeds.push_back(ctx.newShaderDataBinding(pipeline, newInst.GetBooVBO(*this, ctx), nullptr, m_staticIbo.get(),
|
||||
4, bufs, stages, thisOffs, thisSizes, 12, texs, nullptr, nullptr));
|
||||
idx = EExtendedShader(size_t(idx) + 1);
|
||||
}
|
||||
}
|
||||
|
||||
return &newInst;
|
||||
}
|
||||
|
@ -450,20 +502,6 @@ void CBooModel::RemapMaterialData(SShader& shader) {
|
|||
m_geomLayout = &*shader.m_geomLayout;
|
||||
m_matSetIdx = shader.m_matSetIdx;
|
||||
x1c_textures = shader.x0_textures;
|
||||
m_pipelines = &shader.m_shaders;
|
||||
x40_24_texturesLoaded = false;
|
||||
m_instances.clear();
|
||||
}
|
||||
|
||||
void CBooModel::RemapMaterialData(SShader& shader,
|
||||
const std::unordered_map<int, CModelShaders::ShaderPipelines>& pipelines) {
|
||||
if (!shader.m_geomLayout)
|
||||
return;
|
||||
x4_matSet = &shader.m_matSet;
|
||||
m_geomLayout = &*shader.m_geomLayout;
|
||||
m_matSetIdx = shader.m_matSetIdx;
|
||||
x1c_textures = shader.x0_textures;
|
||||
m_pipelines = &pipelines;
|
||||
x40_24_texturesLoaded = false;
|
||||
m_instances.clear();
|
||||
}
|
||||
|
@ -478,20 +516,6 @@ bool CBooModel::TryLockTextures() {
|
|||
}
|
||||
}
|
||||
|
||||
if (allLoad) {
|
||||
for (auto& pipeline : *m_pipelines) {
|
||||
for (auto& subpipeline : *pipeline.second) {
|
||||
if (!subpipeline->isReady()) {
|
||||
allLoad = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!allLoad) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
x40_24_texturesLoaded = allLoad;
|
||||
}
|
||||
|
||||
|
@ -598,17 +622,17 @@ static EExtendedShader ResolveExtendedShader(const MaterialSet::Material& data,
|
|||
extended = EExtendedShader::ForcedAdditiveNoZWriteDepthGreater;
|
||||
else
|
||||
extended =
|
||||
flags.m_noCull
|
||||
? (noZWrite ? EExtendedShader::ForcedAdditiveNoCullNoZWrite : EExtendedShader::ForcedAdditiveNoCull)
|
||||
: (noZWrite ? EExtendedShader::ForcedAdditiveNoZWrite : EExtendedShader::ForcedAdditive);
|
||||
flags.m_noCull
|
||||
? (noZWrite ? EExtendedShader::ForcedAdditiveNoCullNoZWrite : EExtendedShader::ForcedAdditiveNoCull)
|
||||
: (noZWrite ? EExtendedShader::ForcedAdditiveNoZWrite : EExtendedShader::ForcedAdditive);
|
||||
} else if (flags.x0_blendMode > 4) {
|
||||
extended = flags.m_noCull
|
||||
? (noZWrite ? EExtendedShader::ForcedAlphaNoCullNoZWrite : EExtendedShader::ForcedAlphaNoCull)
|
||||
: (noZWrite ? EExtendedShader::ForcedAlphaNoZWrite : EExtendedShader::ForcedAlpha);
|
||||
? (noZWrite ? EExtendedShader::ForcedAlphaNoCullNoZWrite : EExtendedShader::ForcedAlphaNoCull)
|
||||
: (noZWrite ? EExtendedShader::ForcedAlphaNoZWrite : EExtendedShader::ForcedAlpha);
|
||||
} else {
|
||||
extended = flags.m_noCull
|
||||
? (noZWrite ? EExtendedShader::ForcedAlphaNoCullNoZWrite : EExtendedShader::ForcedAlphaNoCull)
|
||||
: (noZWrite ? EExtendedShader::ForcedAlphaNoZWrite : EExtendedShader::Lighting);
|
||||
? (noZWrite ? EExtendedShader::ForcedAlphaNoCullNoZWrite : EExtendedShader::ForcedAlphaNoCull)
|
||||
: (noZWrite ? EExtendedShader::ForcedAlphaNoZWrite : EExtendedShader::Lighting);
|
||||
}
|
||||
} else if (flags.m_noCull && noZWrite) {
|
||||
/* Substitute no-cull,no-zwrite pipeline if available */
|
||||
|
@ -948,35 +972,56 @@ void GeometryUniformLayout::Update(const CModelFlags& flags, const CSkinRules* c
|
|||
buf->unmap();
|
||||
}
|
||||
|
||||
void GeometryUniformLayout::ReserveSharedBuffers(boo::IGraphicsDataFactory::Context& ctx, int size) {
|
||||
if (m_sharedBuffer.size() < size)
|
||||
m_sharedBuffer.resize(size);
|
||||
for (int i = 0; i < size; ++i) {
|
||||
auto& buf = m_sharedBuffer[i];
|
||||
if (!buf)
|
||||
buf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, m_geomBufferSize, 1);
|
||||
hsh::dynamic_owner<hsh::uniform_buffer_typeless> GeometryUniformLayout::AllocateVertUniformBuffer() const {
|
||||
switch (m_weightVecCount * 4) {
|
||||
#define VERT_UNIFORM(SkinSlotCount) \
|
||||
case SkinSlotCount: \
|
||||
return hsh::create_dynamic_uniform_buffer<CModelShaders::VertUniform<SkinSlotCount>>();
|
||||
VERT_UNIFORM(0)
|
||||
VERT_UNIFORM(4)
|
||||
VERT_UNIFORM(8)
|
||||
VERT_UNIFORM(12)
|
||||
VERT_UNIFORM(16)
|
||||
#undef VERT_UNIFORM
|
||||
default:
|
||||
assert(false && "Unhandled vertex uniform size");
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
boo::ObjToken<boo::IGraphicsBufferD> GeometryUniformLayout::GetSharedBuffer(int idx) const {
|
||||
if (idx >= m_sharedBuffer.size())
|
||||
void GeometryUniformLayout::ReserveSharedBuffers(size_t size) {
|
||||
if (m_sharedBuffer.size() < size) {
|
||||
m_sharedBuffer.resize(size);
|
||||
}
|
||||
|
||||
for (int i = 0; i < size; ++i) {
|
||||
auto& buf = m_sharedBuffer[i];
|
||||
if (!buf) {
|
||||
buf = AllocateVertUniformBuffer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
hsh::uniform_buffer_typeless GeometryUniformLayout::GetSharedBuffer(size_t idx) const {
|
||||
if (idx >= m_sharedBuffer.size()) {
|
||||
m_sharedBuffer.resize(idx + 1);
|
||||
}
|
||||
|
||||
auto& buf = m_sharedBuffer[idx];
|
||||
if (!buf) {
|
||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
||||
buf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, m_geomBufferSize, 1);
|
||||
return true;
|
||||
} BooTrace);
|
||||
buf = AllocateVertUniformBuffer();
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
boo::ObjToken<boo::IGraphicsBufferD> CBooModel::UpdateUniformData(const CModelFlags& flags, const CSkinRules* cskr,
|
||||
const CPoseAsTransforms* pose, int sharedLayoutBuf) {
|
||||
if (!g_DummyTextures && !TryLockTextures())
|
||||
return {};
|
||||
hsh::dynamic_owner<hsh::vertex_buffer_typeless>* CBooModel::UpdateUniformData(const CModelFlags& flags,
|
||||
const CSkinRules* cskr,
|
||||
const CPoseAsTransforms* pose,
|
||||
int sharedLayoutBuf) {
|
||||
if (!g_DummyTextures && !TryLockTextures()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* Invalidate instances if new shadow being drawn */
|
||||
if ((flags.m_extendedShader == EExtendedShader::WorldShadow ||
|
||||
|
@ -993,20 +1038,21 @@ boo::ObjToken<boo::IGraphicsBufferD> CBooModel::UpdateUniformData(const CModelFl
|
|||
}
|
||||
|
||||
/* Invalidate instances if new reflection cube being drawn */
|
||||
if (hecl::com_cubemaps->toBoolean() && (flags.m_extendedShader == EExtendedShader::LightingCubeReflection ||
|
||||
if (hecl::com_cubemaps->toBoolean() &&
|
||||
(flags.m_extendedShader == EExtendedShader::LightingCubeReflection ||
|
||||
flags.m_extendedShader == EExtendedShader::LightingCubeReflectionWorldShadow) &&
|
||||
m_lastDrawnReflectionCube != g_reflectionCube) {
|
||||
m_lastDrawnReflectionCube = g_reflectionCube;
|
||||
m_instances.clear();
|
||||
}
|
||||
|
||||
const ModelInstance* inst;
|
||||
ModelInstance* inst = nullptr;
|
||||
if (sharedLayoutBuf >= 0) {
|
||||
if (m_instances.size() <= sharedLayoutBuf) {
|
||||
do {
|
||||
inst = PushNewModelInstance(m_instances.size());
|
||||
if (!inst) {
|
||||
return {};
|
||||
return nullptr;
|
||||
}
|
||||
} while (m_instances.size() <= sharedLayoutBuf);
|
||||
} else {
|
||||
|
@ -1017,7 +1063,7 @@ boo::ObjToken<boo::IGraphicsBufferD> CBooModel::UpdateUniformData(const CModelFl
|
|||
if (m_instances.size() <= m_uniUpdateCount) {
|
||||
inst = PushNewModelInstance(sharedLayoutBuf);
|
||||
if (!inst) {
|
||||
return {};
|
||||
return nullptr;
|
||||
}
|
||||
} else {
|
||||
inst = &m_instances[m_uniUpdateCount];
|
||||
|
@ -1029,7 +1075,7 @@ boo::ObjToken<boo::IGraphicsBufferD> CBooModel::UpdateUniformData(const CModelFl
|
|||
m_geomLayout->Update(flags, cskr, pose, x4_matSet, inst->m_geomUniformBuffer, this);
|
||||
}
|
||||
|
||||
u8* dataOut = reinterpret_cast<u8*>(inst->m_uniformBuffer->map(m_uniformDataSize));
|
||||
u8* dataOut = reinterpret_cast<u8*>(inst->m_uniformBuffer.map());
|
||||
u8* dataCur = dataOut;
|
||||
|
||||
if (flags.m_extendedShader == EExtendedShader::Thermal) /* Thermal Model (same as UV Mode 0) */
|
||||
|
@ -1079,8 +1125,8 @@ boo::ObjToken<boo::IGraphicsBufferD> CBooModel::UpdateUniformData(const CModelFl
|
|||
}
|
||||
}
|
||||
|
||||
inst->m_uniformBuffer->unmap();
|
||||
return inst->m_dynamicVbo;
|
||||
inst->m_uniformBuffer.unmap();
|
||||
return &inst->m_dynamicVbo;
|
||||
}
|
||||
|
||||
void CBooModel::DrawAlpha(const CModelFlags& flags, const CSkinRules* cskr, const CPoseAsTransforms* pose) {
|
||||
|
@ -1146,27 +1192,6 @@ std::unique_ptr<CBooModel> CModel::MakeNewInstance(int shaderIdx, int subInsts,
|
|||
return ret;
|
||||
}
|
||||
|
||||
CModelShaders::ShaderPipelines SShader::BuildShader(const hecl::HMDLMeta& meta, const MaterialSet::Material& mat) {
|
||||
hecl::Backend::ReflectionType reflectionType;
|
||||
if (mat.flags.samusReflectionIndirectTexture())
|
||||
reflectionType = hecl::Backend::ReflectionType::Indirect;
|
||||
else if (mat.flags.samusReflection() || mat.flags.samusReflectionSurfaceEye())
|
||||
reflectionType = hecl::Backend::ReflectionType::Simple;
|
||||
else
|
||||
reflectionType = hecl::Backend::ReflectionType::None;
|
||||
hecl::Backend::ShaderTag tag(mat.hash, meta.colorCount, meta.uvCount, meta.weightCount, meta.weightCount * 4,
|
||||
boo::Primitive(meta.topology), reflectionType, true, true, true, mat.flags.alphaTest());
|
||||
return CModelShaders::BuildExtendedShader(tag, mat);
|
||||
}
|
||||
|
||||
void SShader::BuildShaders(const hecl::HMDLMeta& meta,
|
||||
std::unordered_map<int, CModelShaders::ShaderPipelines>& shaders) {
|
||||
shaders.reserve(m_matSet.materials.size());
|
||||
int idx = 0;
|
||||
for (const MaterialSet::Material& mat : m_matSet.materials)
|
||||
shaders[idx++] = BuildShader(meta, mat);
|
||||
}
|
||||
|
||||
CModel::CModel(std::unique_ptr<u8[]>&& in, u32 /* dataLen */, IObjectStore* store, CObjectReference* selfRef)
|
||||
: m_selfToken(selfRef) {
|
||||
x38_lastFrame = CGraphics::GetFrameCounter() - 2;
|
||||
|
@ -1294,7 +1319,7 @@ zeus::CVector3f CModel::GetPoolNormal(size_t idx) const {
|
|||
return {floats};
|
||||
}
|
||||
|
||||
void CModel::ApplyVerticesCPU(const boo::ObjToken<boo::IGraphicsBufferD>& vertBuf,
|
||||
void CModel::ApplyVerticesCPU(hsh::owner<hsh::vertex_buffer_typeless>& vertBuf,
|
||||
const std::vector<std::pair<zeus::CVector3f, zeus::CVector3f>>& vn) const {
|
||||
u8* data = reinterpret_cast<u8*>(vertBuf->map(m_hmdlMeta.vertStride * m_hmdlMeta.vertCount));
|
||||
for (u32 i = 0; i < std::min(u32(vn.size()), m_hmdlMeta.vertCount); ++i) {
|
||||
|
@ -1310,7 +1335,7 @@ void CModel::ApplyVerticesCPU(const boo::ObjToken<boo::IGraphicsBufferD>& vertBu
|
|||
vertBuf->unmap();
|
||||
}
|
||||
|
||||
void CModel::RestoreVerticesCPU(const boo::ObjToken<boo::IGraphicsBufferD>& vertBuf) const {
|
||||
void CModel::RestoreVerticesCPU(hsh::owner<hsh::vertex_buffer_typeless>& vertBuf) const {
|
||||
size_t size = m_hmdlMeta.vertStride * m_hmdlMeta.vertCount;
|
||||
u8* data = reinterpret_cast<u8*>(vertBuf->map(size));
|
||||
memcpy(data, m_dynamicVertexData.get(), size);
|
||||
|
|
|
@ -5,12 +5,30 @@
|
|||
#include "Runtime/Graphics/CGraphics.hpp"
|
||||
|
||||
#include <amuse/DSPCodec.hpp>
|
||||
#include <boo/graphicsdev/GLSLMacros.hpp>
|
||||
#include <hecl/Pipeline.hpp>
|
||||
#include <specter/View.hpp>
|
||||
#include <turbojpeg.h>
|
||||
|
||||
#include "CMoviePlayer.cpp.hshhead"
|
||||
|
||||
namespace urde {
|
||||
using namespace hsh::pipeline;
|
||||
|
||||
struct CMoviePlayerPipeline : pipeline<color_attachment<>> {
|
||||
CMoviePlayerPipeline(hsh::vertex_buffer<TexUVVert> vbo, hsh::uniform_buffer<ViewBlock> uniBuf, hsh::texture2d Y,
|
||||
hsh::texture2d U, hsh::texture2d V) {
|
||||
position = uniBuf->m_mv * hsh::float4(vbo->m_pos, 1.0);
|
||||
|
||||
hsh::float3 yuv;
|
||||
yuv.x = Y.sample<float>(vbo->m_uv).x;
|
||||
yuv.y = U.sample<float>(vbo->m_uv).x;
|
||||
yuv.z = V.sample<float>(vbo->m_uv).x;
|
||||
yuv.x = 1.1643 * (yuv.x - 0.0625);
|
||||
yuv.y = yuv.y - 0.5;
|
||||
yuv.z = yuv.z - 0.5;
|
||||
color_out[0] =
|
||||
hsh::float4(yuv.x + 1.5958 * yuv.z, yuv.x - 0.39173 * yuv.y - 0.81290 * yuv.z, yuv.x + 2.017 * yuv.y, 1.0) *
|
||||
uniBuf->m_color;
|
||||
}
|
||||
};
|
||||
|
||||
/* used in the original to look up fixed-point dividends on a
|
||||
* MIDI-style volume scale (0-127) -> (n/0x8000) */
|
||||
|
@ -27,7 +45,6 @@ static const u16 StaticVolumeLookup[] = {
|
|||
0x6CA2, 0x6E80, 0x7061, 0x7247, 0x7430, 0x761E, 0x7810, 0x7A06, 0x7C00, 0x7DFE, 0x8000};
|
||||
|
||||
/* shared boo resources */
|
||||
static boo::ObjToken<boo::IShaderPipeline> YUVShaderPipeline;
|
||||
static tjhandle TjHandle = nullptr;
|
||||
|
||||
/* RSF audio state */
|
||||
|
@ -46,15 +63,9 @@ static float SfxVolume = 1.f;
|
|||
static const char* BlockNames[] = {"SpecterViewBlock"};
|
||||
static const char* TexNames[] = {"texY", "texU", "texV"};
|
||||
|
||||
void CMoviePlayer::Initialize() {
|
||||
YUVShaderPipeline = hecl::conv->convert(Shader_CMoviePlayerShader{});
|
||||
TjHandle = tjInitDecompress();
|
||||
}
|
||||
void CMoviePlayer::Initialize() { TjHandle = tjInitDecompress(); }
|
||||
|
||||
void CMoviePlayer::Shutdown() {
|
||||
YUVShaderPipeline.reset();
|
||||
tjDestroy(TjHandle);
|
||||
}
|
||||
void CMoviePlayer::Shutdown() { tjDestroy(TjHandle); }
|
||||
|
||||
void CMoviePlayer::THPHeader::swapBig() {
|
||||
magic = hecl::SBig(magic);
|
||||
|
@ -149,12 +160,12 @@ CMoviePlayer::CMoviePlayer(const char* path, float preLoadSeconds, bool loop, bo
|
|||
/* Read THP header information */
|
||||
u8 buf[64];
|
||||
SyncRead(buf, 64);
|
||||
memmove(&x28_thpHead, buf, 48);
|
||||
std::memcpy(&x28_thpHead, buf, 48);
|
||||
x28_thpHead.swapBig();
|
||||
|
||||
u32 cur = x28_thpHead.componentDataOffset;
|
||||
SyncSeekRead(buf, 32, ESeekOrigin::Begin, cur);
|
||||
memmove(&x58_thpComponents, buf, 20);
|
||||
std::memcpy(&x58_thpComponents, buf, 20);
|
||||
cur += 20;
|
||||
x58_thpComponents.swapBig();
|
||||
|
||||
|
@ -162,13 +173,13 @@ CMoviePlayer::CMoviePlayer(const char* path, float preLoadSeconds, bool loop, bo
|
|||
switch (x58_thpComponents.comps[i]) {
|
||||
case THPComponents::Type::Video:
|
||||
SyncSeekRead(buf, 32, ESeekOrigin::Begin, cur);
|
||||
memmove(&x6c_videoInfo, buf, 8);
|
||||
std::memcpy(&x6c_videoInfo, buf, 8);
|
||||
cur += 8;
|
||||
x6c_videoInfo.swapBig();
|
||||
break;
|
||||
case THPComponents::Type::Audio:
|
||||
SyncSeekRead(buf, 32, ESeekOrigin::Begin, cur);
|
||||
memmove(&x74_audioInfo, buf, 12);
|
||||
std::memcpy(&x74_audioInfo, buf, 12);
|
||||
cur += 12;
|
||||
x74_audioInfo.swapBig();
|
||||
xf4_25_hasAudio = true;
|
||||
|
@ -200,50 +211,36 @@ CMoviePlayer::CMoviePlayer(const char* path, float preLoadSeconds, bool loop, bo
|
|||
xa0_bufferQueue.reserve(xf0_preLoadFrames);
|
||||
|
||||
/* All set for GPU resources */
|
||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
||||
m_blockBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(m_viewVertBlock), 1);
|
||||
m_vertBuf = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(specter::View::TexShaderVert), 4);
|
||||
m_blockBuf = hsh::create_dynamic_uniform_buffer<ViewBlock>();
|
||||
m_vertBuf = hsh::create_dynamic_vertex_buffer<TexUVVert>(4);
|
||||
|
||||
/* Allocate textures here (rather than at decode time) */
|
||||
x80_textures.reserve(3);
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
CTHPTextureSet& set = x80_textures.emplace_back();
|
||||
if (deinterlace) {
|
||||
/* urde addition: this way interlaced THPs don't look horrible */
|
||||
set.Y[0] = ctx.newDynamicTexture(x6c_videoInfo.width, x6c_videoInfo.height / 2, boo::TextureFormat::I8,
|
||||
boo::TextureClampMode::Repeat);
|
||||
set.Y[1] = ctx.newDynamicTexture(x6c_videoInfo.width, x6c_videoInfo.height / 2, boo::TextureFormat::I8,
|
||||
boo::TextureClampMode::Repeat);
|
||||
set.U = ctx.newDynamicTexture(x6c_videoInfo.width / 2, x6c_videoInfo.height / 2, boo::TextureFormat::I8,
|
||||
boo::TextureClampMode::Repeat);
|
||||
set.V = ctx.newDynamicTexture(x6c_videoInfo.width / 2, x6c_videoInfo.height / 2, boo::TextureFormat::I8,
|
||||
boo::TextureClampMode::Repeat);
|
||||
/* Allocate textures here (rather than at decode time) */
|
||||
x80_textures.reserve(3);
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
CTHPTextureSet& set = x80_textures.emplace_back();
|
||||
if (deinterlace) {
|
||||
/* urde addition: this way interlaced THPs don't look horrible */
|
||||
set.Y[0] = hsh::create_dynamic_texture2d({x6c_videoInfo.width, x6c_videoInfo.height / 2}, hsh::R8_UNORM, 1);
|
||||
set.Y[0] = hsh::create_dynamic_texture2d({x6c_videoInfo.width, x6c_videoInfo.height / 2}, hsh::R8_UNORM, 1);
|
||||
set.U = hsh::create_dynamic_texture2d({x6c_videoInfo.width / 2, x6c_videoInfo.height / 2}, hsh::R8_UNORM, 1);
|
||||
set.V = hsh::create_dynamic_texture2d({x6c_videoInfo.width / 2, x6c_videoInfo.height / 2}, hsh::R8_UNORM, 1);
|
||||
|
||||
boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {m_blockBuf.get()};
|
||||
for (int j = 0; j < 2; ++j) {
|
||||
boo::ObjToken<boo::ITexture> texs[] = {set.Y[j].get(), set.U.get(), set.V.get()};
|
||||
set.binding[j] = ctx.newShaderDataBinding(YUVShaderPipeline, m_vertBuf.get(), nullptr, nullptr, 1, bufs,
|
||||
nullptr, 3, texs, nullptr, nullptr);
|
||||
}
|
||||
} else {
|
||||
/* normal progressive presentation */
|
||||
set.Y[0] = ctx.newDynamicTexture(x6c_videoInfo.width, x6c_videoInfo.height, boo::TextureFormat::I8,
|
||||
boo::TextureClampMode::Repeat);
|
||||
set.U = ctx.newDynamicTexture(x6c_videoInfo.width / 2, x6c_videoInfo.height / 2, boo::TextureFormat::I8,
|
||||
boo::TextureClampMode::Repeat);
|
||||
set.V = ctx.newDynamicTexture(x6c_videoInfo.width / 2, x6c_videoInfo.height / 2, boo::TextureFormat::I8,
|
||||
boo::TextureClampMode::Repeat);
|
||||
set.binding[0].hsh_bind_even(
|
||||
CMoviePlayerPipeline(m_vertBuf.get(), m_blockBuf.get(), set.Y[0].get(), set.U.get(), set.V.get()));
|
||||
set.binding[1].hsh_bind_odd(
|
||||
CMoviePlayerPipeline(m_vertBuf.get(), m_blockBuf.get(), set.Y[1].get(), set.U.get(), set.V.get()));
|
||||
} else {
|
||||
/* normal progressive presentation */
|
||||
set.Y[0] = hsh::create_dynamic_texture2d({x6c_videoInfo.width, x6c_videoInfo.height}, hsh::R8_UNORM, 1);
|
||||
set.U = hsh::create_dynamic_texture2d({x6c_videoInfo.width / 2, x6c_videoInfo.height / 2}, hsh::R8_UNORM, 1);
|
||||
set.V = hsh::create_dynamic_texture2d({x6c_videoInfo.width / 2, x6c_videoInfo.height / 2}, hsh::R8_UNORM, 1);
|
||||
|
||||
boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {m_blockBuf.get()};
|
||||
boo::ObjToken<boo::ITexture> texs[] = {set.Y[0].get(), set.U.get(), set.V.get()};
|
||||
set.binding[0] = ctx.newShaderDataBinding(YUVShaderPipeline, m_vertBuf.get(), nullptr, nullptr, 1, bufs,
|
||||
nullptr, 3, texs, nullptr, nullptr);
|
||||
}
|
||||
if (xf4_25_hasAudio)
|
||||
set.audioBuf.reset(new s16[x28_thpHead.maxAudioSamples * 2]);
|
||||
set.binding[0].hsh_bind_prog(
|
||||
CMoviePlayerPipeline(m_vertBuf.get(), m_blockBuf.get(), set.Y[0].get(), set.U.get(), set.V.get()));
|
||||
}
|
||||
return true;
|
||||
} BooTrace);
|
||||
if (xf4_25_hasAudio)
|
||||
set.audioBuf.reset(new s16[x28_thpHead.maxAudioSamples * 2]);
|
||||
}
|
||||
|
||||
/* Temporary planar YUV decode buffer, resulting planes copied to Boo */
|
||||
m_yuvBuf.reset(new uint8_t[tjBufSizeYUV(x6c_videoInfo.width, x6c_videoInfo.height, TJ_420)]);
|
||||
|
@ -258,7 +255,7 @@ CMoviePlayer::CMoviePlayer(const char* path, float preLoadSeconds, bool loop, bo
|
|||
SetFrame({-0.5f, 0.5f, 0.f}, {-0.5f, -0.5f, 0.f}, {0.5f, -0.5f, 0.f}, {0.5f, 0.5f, 0.f});
|
||||
|
||||
m_viewVertBlock.finalAssign(m_viewVertBlock);
|
||||
m_blockBuf->load(&m_viewVertBlock, sizeof(m_viewVertBlock));
|
||||
m_blockBuf.load(m_viewVertBlock);
|
||||
}
|
||||
|
||||
void CMoviePlayer::SetStaticAudioVolume(int vol) {
|
||||
|
@ -282,9 +279,9 @@ void CMoviePlayer::MixAudio(s16* out, const s16* in, u32 samples) {
|
|||
/* No audio frames ready */
|
||||
if (xd4_audioSlot == UINT32_MAX) {
|
||||
if (in)
|
||||
memmove(out, in, samples * 4);
|
||||
std::memcpy(out, in, samples * 4);
|
||||
else
|
||||
memset(out, 0, samples * 4);
|
||||
std::memset(out, 0, samples * 4);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -319,9 +316,9 @@ void CMoviePlayer::MixAudio(s16* out, const s16* in, u32 samples) {
|
|||
} else {
|
||||
/* urde addition: failsafe for buffer overrun */
|
||||
if (in)
|
||||
memmove(out, in, samples * 4);
|
||||
std::memcpy(out, in, samples * 4);
|
||||
else
|
||||
memset(out, 0, samples * 4);
|
||||
std::memset(out, 0, samples * 4);
|
||||
// fprintf(stderr, "dropped %d samples\n", samples);
|
||||
return;
|
||||
}
|
||||
|
@ -403,7 +400,7 @@ void CMoviePlayer::SetFrame(const zeus::CVector3f& a, const zeus::CVector3f& b,
|
|||
m_frame[1].m_pos = b;
|
||||
m_frame[2].m_pos = d;
|
||||
m_frame[3].m_pos = c;
|
||||
m_vertBuf->load(m_frame, sizeof(m_frame));
|
||||
m_vertBuf.load(m_frame);
|
||||
}
|
||||
|
||||
void CMoviePlayer::DrawFrame() {
|
||||
|
@ -413,8 +410,7 @@ void CMoviePlayer::DrawFrame() {
|
|||
|
||||
/* draw appropriate field */
|
||||
CTHPTextureSet& tex = x80_textures[xd0_drawTexSlot];
|
||||
CGraphics::SetShaderDataBinding(tex.binding[m_deinterlace ? (xfc_fieldIndex != 0) : 0]);
|
||||
CGraphics::DrawArray(0, 4);
|
||||
tex.binding[m_deinterlace ? (xfc_fieldIndex != 0) : 0].draw(0, 4);
|
||||
|
||||
/* ensure second field is being displayed by VI to signal advance
|
||||
* (faked in urde with continuous xor) */
|
||||
|
@ -530,33 +526,33 @@ void CMoviePlayer::DecodeFromRead(const void* data) {
|
|||
|
||||
if (m_deinterlace) {
|
||||
/* Deinterlace into 2 discrete 60-fps half-res textures */
|
||||
u8* mappedData = (u8*)tex.Y[0]->map(planeSizeHalf);
|
||||
u8* mappedData = (u8*)tex.Y[0].map();
|
||||
for (unsigned y = 0; y < x6c_videoInfo.height / 2; ++y) {
|
||||
memmove(mappedData + x6c_videoInfo.width * y, m_yuvBuf.get() + x6c_videoInfo.width * (y * 2),
|
||||
x6c_videoInfo.width);
|
||||
std::memcpy(mappedData + x6c_videoInfo.width * y, m_yuvBuf.get() + x6c_videoInfo.width * (y * 2),
|
||||
x6c_videoInfo.width);
|
||||
}
|
||||
tex.Y[0]->unmap();
|
||||
tex.Y[0].unmap();
|
||||
|
||||
mappedData = (u8*)tex.Y[1]->map(planeSizeHalf);
|
||||
mappedData = (u8*)tex.Y[1].map();
|
||||
for (unsigned y = 0; y < x6c_videoInfo.height / 2; ++y) {
|
||||
memmove(mappedData + x6c_videoInfo.width * y, m_yuvBuf.get() + x6c_videoInfo.width * (y * 2 + 1),
|
||||
x6c_videoInfo.width);
|
||||
std::memcpy(mappedData + x6c_videoInfo.width * y, m_yuvBuf.get() + x6c_videoInfo.width * (y * 2 + 1),
|
||||
x6c_videoInfo.width);
|
||||
}
|
||||
tex.Y[1]->unmap();
|
||||
tex.Y[1].unmap();
|
||||
|
||||
tex.U->load(m_yuvBuf.get() + planeSize, planeSizeQuarter);
|
||||
tex.V->load(m_yuvBuf.get() + planeSize + planeSizeQuarter, planeSizeQuarter);
|
||||
tex.U.load(m_yuvBuf.get() + planeSize, planeSizeQuarter);
|
||||
tex.V.load(m_yuvBuf.get() + planeSize + planeSizeQuarter, planeSizeQuarter);
|
||||
} else {
|
||||
/* Direct planar load */
|
||||
tex.Y[0]->load(m_yuvBuf.get(), planeSize);
|
||||
tex.U->load(m_yuvBuf.get() + planeSize, planeSizeQuarter);
|
||||
tex.V->load(m_yuvBuf.get() + planeSize + planeSizeQuarter, planeSizeQuarter);
|
||||
tex.Y[0].load(m_yuvBuf.get(), planeSize);
|
||||
tex.U.load(m_yuvBuf.get() + planeSize, planeSizeQuarter);
|
||||
tex.V.load(m_yuvBuf.get() + planeSize + planeSizeQuarter, planeSizeQuarter);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case THPComponents::Type::Audio:
|
||||
memset(tex.audioBuf.get(), 0, x28_thpHead.maxAudioSamples * 4);
|
||||
std::memset(tex.audioBuf.get(), 0, x28_thpHead.maxAudioSamples * 4);
|
||||
tex.audioSamples = THPAudioDecode(tex.audioBuf.get(), (u8*)inptr, x74_audioInfo.numChannels == 2);
|
||||
tex.playedSamples = 0;
|
||||
inptr += frameHeader.audioSize;
|
||||
|
|
|
@ -6,9 +6,7 @@
|
|||
#include "Runtime/CDvdFile.hpp"
|
||||
#include "Runtime/RetroTypes.hpp"
|
||||
|
||||
#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
||||
#include <specter/View.hpp>
|
||||
#include <zeus/CVector3f.hpp>
|
||||
#include "Graphics/CGraphics.hpp"
|
||||
|
||||
namespace urde {
|
||||
|
||||
|
@ -69,13 +67,13 @@ private:
|
|||
};
|
||||
|
||||
struct CTHPTextureSet {
|
||||
boo::ObjToken<boo::ITextureD> Y[2];
|
||||
boo::ObjToken<boo::ITextureD> U;
|
||||
boo::ObjToken<boo::ITextureD> V;
|
||||
std::array<hsh::dynamic_owner<hsh::texture2d>, 2> Y;
|
||||
hsh::dynamic_owner<hsh::texture2d> U;
|
||||
hsh::dynamic_owner<hsh::texture2d> V;
|
||||
u32 playedSamples = 0;
|
||||
u32 audioSamples = 0;
|
||||
std::unique_ptr<s16[]> audioBuf;
|
||||
boo::ObjToken<boo::IShaderDataBinding> binding[2];
|
||||
std::array<hsh::binding, 2> binding;
|
||||
};
|
||||
std::vector<CTHPTextureSet> x80_textures;
|
||||
std::unique_ptr<uint8_t[]> x90_requestBuf;
|
||||
|
@ -108,11 +106,11 @@ private:
|
|||
|
||||
std::unique_ptr<uint8_t[]> m_yuvBuf;
|
||||
|
||||
specter::View::ViewBlock m_viewVertBlock;
|
||||
boo::ObjToken<boo::IGraphicsBufferD> m_blockBuf;
|
||||
boo::ObjToken<boo::IGraphicsBufferD> m_vertBuf;
|
||||
ViewBlock m_viewVertBlock;
|
||||
hsh::dynamic_owner<hsh::uniform_buffer<ViewBlock>> m_blockBuf;
|
||||
|
||||
specter::View::TexShaderVert m_frame[4];
|
||||
std::array<TexUVVert, 4> m_frame;
|
||||
hsh::dynamic_owner<hsh::vertex_buffer<TexUVVert>> m_vertBuf;
|
||||
|
||||
static u32 THPAudioDecode(s16* buffer, const u8* audioFrame, bool stereo);
|
||||
void DecodeFromRead(const void* data);
|
||||
|
|
|
@ -24,7 +24,7 @@ class CRainSplashGenerator {
|
|||
u8 x15_length = 1;
|
||||
bool x16_active = true; // used to be one-bit bitfield
|
||||
CLineRenderer m_renderer;
|
||||
explicit SSplashLine(boo::IGraphicsDataFactory::Context& ctx);
|
||||
explicit SSplashLine();
|
||||
void Update(float dt, CStateManager& mgr);
|
||||
void Draw(float alpha, float dt, const zeus::CVector3f& pos);
|
||||
void SetActive() { x16_active = true; }
|
||||
|
@ -33,7 +33,7 @@ class CRainSplashGenerator {
|
|||
rstl::reserved_vector<SSplashLine, 4> x0_lines;
|
||||
zeus::CVector3f x64_pos;
|
||||
float x70_ = 0.f;
|
||||
explicit SRainSplash(boo::IGraphicsDataFactory::Context& ctx);
|
||||
explicit SRainSplash();
|
||||
SRainSplash(const SRainSplash&) = delete;
|
||||
SRainSplash& operator=(const SRainSplash&) = delete;
|
||||
SRainSplash(SRainSplash&&) = default;
|
||||
|
|
|
@ -32,7 +32,7 @@ void CSkinnedModel::Calculate(const CPoseAsTransforms& pose, const CModelFlags&
|
|||
const std::optional<CVertexMorphEffect>& morphEffect,
|
||||
const float* morphMagnitudes) {
|
||||
if (morphEffect || g_PointGenFunc) {
|
||||
if (boo::ObjToken<boo::IGraphicsBufferD> vertBuf = m_modelInst->UpdateUniformData(drawFlags, nullptr, nullptr)) {
|
||||
if (auto vertBuf = m_modelInst->UpdateUniformData(drawFlags, nullptr, nullptr)) {
|
||||
x10_skinRules->TransformVerticesCPU(m_vertWorkspace, pose, *x4_model);
|
||||
if (morphEffect)
|
||||
morphEffect->MorphVertices(m_vertWorkspace, morphMagnitudes, x10_skinRules, pose);
|
||||
|
@ -42,7 +42,7 @@ void CSkinnedModel::Calculate(const CPoseAsTransforms& pose, const CModelFlags&
|
|||
m_modifiedVBO = true;
|
||||
}
|
||||
} else {
|
||||
if (boo::ObjToken<boo::IGraphicsBufferD> vertBuf =
|
||||
if (auto vertBuf =
|
||||
m_modelInst->UpdateUniformData(drawFlags, x10_skinRules.GetObj(), &pose)) {
|
||||
if (m_modifiedVBO) {
|
||||
x4_model->RestoreVerticesCPU(vertBuf);
|
||||
|
|
|
@ -9,8 +9,6 @@
|
|||
#include "Runtime/IOStreams.hpp"
|
||||
#include "Runtime/Graphics/CGraphics.hpp"
|
||||
|
||||
#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
||||
|
||||
namespace urde {
|
||||
class CVParamTransfer;
|
||||
class CTextureInfo;
|
||||
|
@ -32,8 +30,7 @@ private:
|
|||
u16 x4_w;
|
||||
u16 x6_h;
|
||||
u32 x8_mips;
|
||||
boo::ObjToken<boo::ITexture> m_booTex;
|
||||
boo::ObjToken<boo::ITexture> m_paletteTex;
|
||||
hsh::owner<hsh::texture_typeless> m_booTex, m_paletteTex;
|
||||
std::unique_ptr<u8[]> m_otex;
|
||||
EFontType m_ftype = EFontType::None;
|
||||
const CTextureInfo* m_textureInfo;
|
||||
|
@ -69,10 +66,10 @@ public:
|
|||
u16 GetHeight() const { return x6_h; }
|
||||
u32 GetNumMips() const { return x8_mips; }
|
||||
void Load(int slot, EClampMode clamp) const;
|
||||
const boo::ObjToken<boo::ITexture>& GetBooTexture() const { return m_booTex; }
|
||||
const boo::ObjToken<boo::ITexture>& GetPaletteTexture() const { return m_paletteTex; }
|
||||
hsh::texture_typeless GetBooTexture() const { return m_booTex.get(); }
|
||||
hsh::texture_typeless GetPaletteTexture() const { return m_paletteTex.get(); }
|
||||
std::unique_ptr<u8[]> BuildMemoryCardTex(u32& sizeOut, ETexelFormat& fmtOut, std::unique_ptr<u8[]>& paletteOut) const;
|
||||
const boo::ObjToken<boo::ITexture>& GetFontTexture(EFontType tp);
|
||||
hsh::texture_typeless GetFontTexture(EFontType tp);
|
||||
|
||||
const CTextureInfo* GetTextureInfo() const { return m_textureInfo; }
|
||||
};
|
||||
|
|
|
@ -66,173 +66,145 @@ struct RGBA8 {
|
|||
};
|
||||
|
||||
void CTexture::BuildI4FromGCN(CInputStream& in) {
|
||||
size_t texelCount = ComputeMippedTexelCount();
|
||||
std::unique_ptr<RGBA8[]> buf(new RGBA8[texelCount]);
|
||||
|
||||
int w = x4_w;
|
||||
int h = x6_h;
|
||||
RGBA8* targetMip = buf.get();
|
||||
for (u32 mip = 0; mip < x8_mips; ++mip) {
|
||||
int bwidth = (w + 7) / 8;
|
||||
int bheight = (h + 7) / 8;
|
||||
for (int by = 0; by < bheight; ++by) {
|
||||
int baseY = by * 8;
|
||||
for (int bx = 0; bx < bwidth; ++bx) {
|
||||
int baseX = bx * 8;
|
||||
for (int y = 0; y < 8; ++y) {
|
||||
RGBA8* target = targetMip + (baseY + y) * w + baseX;
|
||||
u8 source[4];
|
||||
in.readBytesToBuf(source, 4);
|
||||
for (int x = 0; x < 8; ++x) {
|
||||
target[x].r = Convert4To8(source[x / 2] >> ((x & 1) ? 0 : 4) & 0xf);
|
||||
target[x].g = target[x].r;
|
||||
target[x].b = target[x].r;
|
||||
target[x].a = target[x].r;
|
||||
m_booTex = hsh::create_texture2d({x4_w, x6_h}, hsh::RGBA8_UNORM, x8_mips, [&](void* data, std::size_t size) {
|
||||
RGBA8* buf = reinterpret_cast<RGBA8*>(data);
|
||||
int w = x4_w;
|
||||
int h = x6_h;
|
||||
RGBA8* targetMip = buf;
|
||||
for (u32 mip = 0; mip < x8_mips; ++mip) {
|
||||
int bwidth = (w + 7) / 8;
|
||||
int bheight = (h + 7) / 8;
|
||||
for (int by = 0; by < bheight; ++by) {
|
||||
int baseY = by * 8;
|
||||
for (int bx = 0; bx < bwidth; ++bx) {
|
||||
int baseX = bx * 8;
|
||||
for (int y = 0; y < 8; ++y) {
|
||||
RGBA8* target = targetMip + (baseY + y) * w + baseX;
|
||||
u8 source[4];
|
||||
in.readBytesToBuf(source, 4);
|
||||
for (int x = 0; x < 8; ++x) {
|
||||
target[x].r = Convert4To8(source[x / 2] >> ((x & 1) ? 0 : 4) & 0xf);
|
||||
target[x].g = target[x].r;
|
||||
target[x].b = target[x].r;
|
||||
target[x].a = target[x].r;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
targetMip += w * h;
|
||||
if (w > 1)
|
||||
w /= 2;
|
||||
if (h > 1)
|
||||
h /= 2;
|
||||
}
|
||||
targetMip += w * h;
|
||||
if (w > 1)
|
||||
w /= 2;
|
||||
if (h > 1)
|
||||
h /= 2;
|
||||
}
|
||||
|
||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
||||
m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::RGBA8, boo::TextureClampMode::Repeat,
|
||||
buf.get(), texelCount * 4)
|
||||
.get();
|
||||
return true;
|
||||
} BooTrace);
|
||||
});
|
||||
}
|
||||
|
||||
void CTexture::BuildI8FromGCN(CInputStream& in) {
|
||||
size_t texelCount = ComputeMippedTexelCount();
|
||||
std::unique_ptr<RGBA8[]> buf(new RGBA8[texelCount]);
|
||||
|
||||
int w = x4_w;
|
||||
int h = x6_h;
|
||||
RGBA8* targetMip = buf.get();
|
||||
for (u32 mip = 0; mip < x8_mips; ++mip) {
|
||||
int bwidth = (w + 7) / 8;
|
||||
int bheight = (h + 3) / 4;
|
||||
for (int by = 0; by < bheight; ++by) {
|
||||
int baseY = by * 4;
|
||||
for (int bx = 0; bx < bwidth; ++bx) {
|
||||
int baseX = bx * 8;
|
||||
for (int y = 0; y < 4; ++y) {
|
||||
RGBA8* target = targetMip + (baseY + y) * w + baseX;
|
||||
u8 source[8];
|
||||
in.readBytesToBuf(source, 8);
|
||||
for (int x = 0; x < 8; ++x) {
|
||||
target[x].r = source[x];
|
||||
target[x].g = source[x];
|
||||
target[x].b = source[x];
|
||||
target[x].a = source[x];
|
||||
m_booTex = hsh::create_texture2d({x4_w, x6_h}, hsh::RGBA8_UNORM, x8_mips, [&](void* data, std::size_t size) {
|
||||
RGBA8* buf = reinterpret_cast<RGBA8*>(data);
|
||||
int w = x4_w;
|
||||
int h = x6_h;
|
||||
RGBA8* targetMip = buf;
|
||||
for (u32 mip = 0; mip < x8_mips; ++mip) {
|
||||
int bwidth = (w + 7) / 8;
|
||||
int bheight = (h + 3) / 4;
|
||||
for (int by = 0; by < bheight; ++by) {
|
||||
int baseY = by * 4;
|
||||
for (int bx = 0; bx < bwidth; ++bx) {
|
||||
int baseX = bx * 8;
|
||||
for (int y = 0; y < 4; ++y) {
|
||||
RGBA8* target = targetMip + (baseY + y) * w + baseX;
|
||||
u8 source[8];
|
||||
in.readBytesToBuf(source, 8);
|
||||
for (int x = 0; x < 8; ++x) {
|
||||
target[x].r = source[x];
|
||||
target[x].g = source[x];
|
||||
target[x].b = source[x];
|
||||
target[x].a = source[x];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
targetMip += w * h;
|
||||
if (w > 1)
|
||||
w /= 2;
|
||||
if (h > 1)
|
||||
h /= 2;
|
||||
}
|
||||
targetMip += w * h;
|
||||
if (w > 1)
|
||||
w /= 2;
|
||||
if (h > 1)
|
||||
h /= 2;
|
||||
}
|
||||
|
||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
||||
m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::RGBA8, boo::TextureClampMode::Repeat,
|
||||
buf.get(), texelCount * 4)
|
||||
.get();
|
||||
return true;
|
||||
} BooTrace);
|
||||
});
|
||||
}
|
||||
|
||||
void CTexture::BuildIA4FromGCN(CInputStream& in) {
|
||||
size_t texelCount = ComputeMippedTexelCount();
|
||||
std::unique_ptr<RGBA8[]> buf(new RGBA8[texelCount]);
|
||||
|
||||
int w = x4_w;
|
||||
int h = x6_h;
|
||||
RGBA8* targetMip = buf.get();
|
||||
for (u32 mip = 0; mip < x8_mips; ++mip) {
|
||||
int bwidth = (w + 7) / 8;
|
||||
int bheight = (h + 3) / 4;
|
||||
for (int by = 0; by < bheight; ++by) {
|
||||
int baseY = by * 4;
|
||||
for (int bx = 0; bx < bwidth; ++bx) {
|
||||
int baseX = bx * 8;
|
||||
for (int y = 0; y < 4; ++y) {
|
||||
RGBA8* target = targetMip + (baseY + y) * w + baseX;
|
||||
u8 source[8];
|
||||
in.readBytesToBuf(source, 8);
|
||||
for (int x = 0; x < 8; ++x) {
|
||||
u8 intensity = Convert4To8(source[x] >> 4 & 0xf);
|
||||
target[x].r = intensity;
|
||||
target[x].g = intensity;
|
||||
target[x].b = intensity;
|
||||
target[x].a = Convert4To8(source[x] & 0xf);
|
||||
m_booTex = hsh::create_texture2d({x4_w, x6_h}, hsh::RGBA8_UNORM, x8_mips, [&](void* data, std::size_t size) {
|
||||
RGBA8* buf = reinterpret_cast<RGBA8*>(data);
|
||||
int w = x4_w;
|
||||
int h = x6_h;
|
||||
RGBA8* targetMip = buf;
|
||||
for (u32 mip = 0; mip < x8_mips; ++mip) {
|
||||
int bwidth = (w + 7) / 8;
|
||||
int bheight = (h + 3) / 4;
|
||||
for (int by = 0; by < bheight; ++by) {
|
||||
int baseY = by * 4;
|
||||
for (int bx = 0; bx < bwidth; ++bx) {
|
||||
int baseX = bx * 8;
|
||||
for (int y = 0; y < 4; ++y) {
|
||||
RGBA8* target = targetMip + (baseY + y) * w + baseX;
|
||||
u8 source[8];
|
||||
in.readBytesToBuf(source, 8);
|
||||
for (int x = 0; x < 8; ++x) {
|
||||
u8 intensity = Convert4To8(source[x] >> 4 & 0xf);
|
||||
target[x].r = intensity;
|
||||
target[x].g = intensity;
|
||||
target[x].b = intensity;
|
||||
target[x].a = Convert4To8(source[x] & 0xf);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
targetMip += w * h;
|
||||
if (w > 1)
|
||||
w /= 2;
|
||||
if (h > 1)
|
||||
h /= 2;
|
||||
}
|
||||
targetMip += w * h;
|
||||
if (w > 1)
|
||||
w /= 2;
|
||||
if (h > 1)
|
||||
h /= 2;
|
||||
}
|
||||
|
||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
||||
m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::RGBA8, boo::TextureClampMode::Repeat,
|
||||
buf.get(), texelCount * 4)
|
||||
.get();
|
||||
return true;
|
||||
} BooTrace);
|
||||
});
|
||||
}
|
||||
|
||||
void CTexture::BuildIA8FromGCN(CInputStream& in) {
|
||||
size_t texelCount = ComputeMippedTexelCount();
|
||||
std::unique_ptr<RGBA8[]> buf(new RGBA8[texelCount]);
|
||||
|
||||
int w = x4_w;
|
||||
int h = x6_h;
|
||||
RGBA8* targetMip = buf.get();
|
||||
for (u32 mip = 0; mip < x8_mips; ++mip) {
|
||||
int bwidth = (w + 3) / 4;
|
||||
int bheight = (h + 3) / 4;
|
||||
for (int by = 0; by < bheight; ++by) {
|
||||
int baseY = by * 4;
|
||||
for (int bx = 0; bx < bwidth; ++bx) {
|
||||
int baseX = bx * 4;
|
||||
for (int y = 0; y < 4; ++y) {
|
||||
RGBA8* target = targetMip + (baseY + y) * w + baseX;
|
||||
u16 source[4];
|
||||
in.readBytesToBuf(source, 8);
|
||||
for (int x = 0; x < 4; ++x) {
|
||||
u8 intensity = source[x] >> 8;
|
||||
target[x].r = intensity;
|
||||
target[x].g = intensity;
|
||||
target[x].b = intensity;
|
||||
target[x].a = source[x] & 0xff;
|
||||
m_booTex = hsh::create_texture2d({x4_w, x6_h}, hsh::RGBA8_UNORM, x8_mips, [&](void* data, std::size_t size) {
|
||||
RGBA8* buf = reinterpret_cast<RGBA8*>(data);
|
||||
int w = x4_w;
|
||||
int h = x6_h;
|
||||
RGBA8* targetMip = buf;
|
||||
for (u32 mip = 0; mip < x8_mips; ++mip) {
|
||||
int bwidth = (w + 3) / 4;
|
||||
int bheight = (h + 3) / 4;
|
||||
for (int by = 0; by < bheight; ++by) {
|
||||
int baseY = by * 4;
|
||||
for (int bx = 0; bx < bwidth; ++bx) {
|
||||
int baseX = bx * 4;
|
||||
for (int y = 0; y < 4; ++y) {
|
||||
RGBA8* target = targetMip + (baseY + y) * w + baseX;
|
||||
u16 source[4];
|
||||
in.readBytesToBuf(source, 8);
|
||||
for (int x = 0; x < 4; ++x) {
|
||||
u8 intensity = source[x] >> 8;
|
||||
target[x].r = intensity;
|
||||
target[x].g = intensity;
|
||||
target[x].b = intensity;
|
||||
target[x].a = source[x] & 0xff;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
targetMip += w * h;
|
||||
if (w > 1)
|
||||
w /= 2;
|
||||
if (h > 1)
|
||||
h /= 2;
|
||||
}
|
||||
targetMip += w * h;
|
||||
if (w > 1)
|
||||
w /= 2;
|
||||
if (h > 1)
|
||||
h /= 2;
|
||||
}
|
||||
|
||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
||||
m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::RGBA8, boo::TextureClampMode::Repeat,
|
||||
buf.get(), texelCount * 4)
|
||||
.get();
|
||||
return true;
|
||||
} BooTrace);
|
||||
});
|
||||
}
|
||||
|
||||
static std::vector<RGBA8> DecodePalette(int numEntries, CInputStream& in) {
|
||||
|
@ -277,308 +249,212 @@ static std::vector<RGBA8> DecodePalette(int numEntries, CInputStream& in) {
|
|||
}
|
||||
|
||||
void CTexture::BuildC4FromGCN(CInputStream& in) {
|
||||
size_t texelCount = ComputeMippedTexelCount();
|
||||
std::unique_ptr<RGBA8[]> buf(new RGBA8[texelCount]);
|
||||
std::vector<RGBA8> palette = DecodePalette(16, in);
|
||||
m_booTex = hsh::create_texture2d({x4_w, x6_h}, hsh::RGBA8_UNORM, x8_mips, [&](void* data, std::size_t size) {
|
||||
RGBA8* buf = reinterpret_cast<RGBA8*>(data);
|
||||
std::vector<RGBA8> palette = DecodePalette(16, in);
|
||||
|
||||
int w = x4_w;
|
||||
int h = x6_h;
|
||||
RGBA8* targetMip = buf.get();
|
||||
for (u32 mip = 0; mip < x8_mips; ++mip) {
|
||||
int bwidth = (w + 7) / 8;
|
||||
int bheight = (h + 7) / 8;
|
||||
for (int by = 0; by < bheight; ++by) {
|
||||
int baseY = by * 8;
|
||||
for (int bx = 0; bx < bwidth; ++bx) {
|
||||
int baseX = bx * 8;
|
||||
for (int y = 0; y < 8; ++y) {
|
||||
RGBA8* target = targetMip + (baseY + y) * w + baseX;
|
||||
u8 source[4];
|
||||
in.readBytesToBuf(source, 4);
|
||||
for (int x = 0; x < 8; ++x)
|
||||
target[x] = palette[source[x / 2] >> ((x & 1) ? 0 : 4) & 0xf];
|
||||
int w = x4_w;
|
||||
int h = x6_h;
|
||||
RGBA8* targetMip = buf;
|
||||
for (u32 mip = 0; mip < x8_mips; ++mip) {
|
||||
int bwidth = (w + 7) / 8;
|
||||
int bheight = (h + 7) / 8;
|
||||
for (int by = 0; by < bheight; ++by) {
|
||||
int baseY = by * 8;
|
||||
for (int bx = 0; bx < bwidth; ++bx) {
|
||||
int baseX = bx * 8;
|
||||
for (int y = 0; y < 8; ++y) {
|
||||
RGBA8* target = targetMip + (baseY + y) * w + baseX;
|
||||
u8 source[4];
|
||||
in.readBytesToBuf(source, 4);
|
||||
for (int x = 0; x < 8; ++x)
|
||||
target[x] = palette[source[x / 2] >> ((x & 1) ? 0 : 4) & 0xf];
|
||||
}
|
||||
}
|
||||
}
|
||||
targetMip += w * h;
|
||||
if (w > 1)
|
||||
w /= 2;
|
||||
if (h > 1)
|
||||
h /= 2;
|
||||
}
|
||||
targetMip += w * h;
|
||||
if (w > 1)
|
||||
w /= 2;
|
||||
if (h > 1)
|
||||
h /= 2;
|
||||
}
|
||||
|
||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
||||
m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::RGBA8, boo::TextureClampMode::Repeat,
|
||||
buf.get(), texelCount * 4)
|
||||
.get();
|
||||
return true;
|
||||
} BooTrace);
|
||||
});
|
||||
}
|
||||
|
||||
void CTexture::BuildC8FromGCN(CInputStream& in) {
|
||||
size_t texelCount = ComputeMippedTexelCount();
|
||||
std::unique_ptr<RGBA8[]> buf(new RGBA8[texelCount]);
|
||||
std::vector<RGBA8> palette = DecodePalette(256, in);
|
||||
m_booTex = hsh::create_texture2d({x4_w, x6_h}, hsh::RGBA8_UNORM, x8_mips, [&](void* data, std::size_t size) {
|
||||
RGBA8* buf = reinterpret_cast<RGBA8*>(data);
|
||||
std::vector<RGBA8> palette = DecodePalette(256, in);
|
||||
|
||||
int w = x4_w;
|
||||
int h = x6_h;
|
||||
RGBA8* targetMip = buf.get();
|
||||
for (u32 mip = 0; mip < x8_mips; ++mip) {
|
||||
int bwidth = (w + 7) / 8;
|
||||
int bheight = (h + 3) / 4;
|
||||
for (int by = 0; by < bheight; ++by) {
|
||||
int baseY = by * 4;
|
||||
for (int bx = 0; bx < bwidth; ++bx) {
|
||||
int baseX = bx * 8;
|
||||
for (int y = 0; y < 4; ++y) {
|
||||
RGBA8* target = targetMip + (baseY + y) * w + baseX;
|
||||
u8 source[8];
|
||||
in.readBytesToBuf(source, 8);
|
||||
for (int x = 0; x < 8; ++x)
|
||||
target[x] = palette[source[x]];
|
||||
int w = x4_w;
|
||||
int h = x6_h;
|
||||
RGBA8* targetMip = buf;
|
||||
for (u32 mip = 0; mip < x8_mips; ++mip) {
|
||||
int bwidth = (w + 7) / 8;
|
||||
int bheight = (h + 3) / 4;
|
||||
for (int by = 0; by < bheight; ++by) {
|
||||
int baseY = by * 4;
|
||||
for (int bx = 0; bx < bwidth; ++bx) {
|
||||
int baseX = bx * 8;
|
||||
for (int y = 0; y < 4; ++y) {
|
||||
RGBA8* target = targetMip + (baseY + y) * w + baseX;
|
||||
u8 source[8];
|
||||
in.readBytesToBuf(source, 8);
|
||||
for (int x = 0; x < 8; ++x)
|
||||
target[x] = palette[source[x]];
|
||||
}
|
||||
}
|
||||
}
|
||||
targetMip += w * h;
|
||||
if (w > 1)
|
||||
w /= 2;
|
||||
if (h > 1)
|
||||
h /= 2;
|
||||
}
|
||||
targetMip += w * h;
|
||||
if (w > 1)
|
||||
w /= 2;
|
||||
if (h > 1)
|
||||
h /= 2;
|
||||
}
|
||||
|
||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
||||
m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::RGBA8, boo::TextureClampMode::Repeat,
|
||||
buf.get(), texelCount * 4)
|
||||
.get();
|
||||
return true;
|
||||
} BooTrace);
|
||||
});
|
||||
}
|
||||
|
||||
void CTexture::BuildC14X2FromGCN(CInputStream& in) {}
|
||||
|
||||
void CTexture::BuildRGB565FromGCN(CInputStream& in) {
|
||||
size_t texelCount = ComputeMippedTexelCount();
|
||||
std::unique_ptr<RGBA8[]> buf(new RGBA8[texelCount]);
|
||||
m_booTex = hsh::create_texture2d({x4_w, x6_h}, hsh::RGBA8_UNORM, x8_mips, [&](void* data, std::size_t size) {
|
||||
RGBA8* buf = reinterpret_cast<RGBA8*>(data);
|
||||
std::vector<RGBA8> palette = DecodePalette(256, in);
|
||||
|
||||
int w = x4_w;
|
||||
int h = x6_h;
|
||||
RGBA8* targetMip = buf.get();
|
||||
for (u32 mip = 0; mip < x8_mips; ++mip) {
|
||||
int bwidth = (w + 3) / 4;
|
||||
int bheight = (h + 3) / 4;
|
||||
for (int by = 0; by < bheight; ++by) {
|
||||
int baseY = by * 4;
|
||||
for (int bx = 0; bx < bwidth; ++bx) {
|
||||
int baseX = bx * 4;
|
||||
for (int y = 0; y < 4; ++y) {
|
||||
RGBA8* target = targetMip + (baseY + y) * w + baseX;
|
||||
for (int x = 0; x < 4; ++x) {
|
||||
u16 texel = in.readUint16Big();
|
||||
target[x].r = Convert5To8(texel >> 11 & 0x1f);
|
||||
target[x].g = Convert6To8(texel >> 5 & 0x3f);
|
||||
target[x].b = Convert5To8(texel & 0x1f);
|
||||
target[x].a = 0xff;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
targetMip += w * h;
|
||||
if (w > 1)
|
||||
w /= 2;
|
||||
if (h > 1)
|
||||
h /= 2;
|
||||
}
|
||||
|
||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
||||
m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::RGBA8, boo::TextureClampMode::Repeat,
|
||||
buf.get(), texelCount * 4)
|
||||
.get();
|
||||
return true;
|
||||
} BooTrace);
|
||||
}
|
||||
|
||||
void CTexture::BuildRGB5A3FromGCN(CInputStream& in) {
|
||||
size_t texelCount = ComputeMippedTexelCount();
|
||||
std::unique_ptr<RGBA8[]> buf(new RGBA8[texelCount]);
|
||||
|
||||
int w = x4_w;
|
||||
int h = x6_h;
|
||||
RGBA8* targetMip = buf.get();
|
||||
for (u32 mip = 0; mip < x8_mips; ++mip) {
|
||||
int bwidth = (w + 3) / 4;
|
||||
int bheight = (h + 3) / 4;
|
||||
for (int by = 0; by < bheight; ++by) {
|
||||
int baseY = by * 4;
|
||||
for (int bx = 0; bx < bwidth; ++bx) {
|
||||
int baseX = bx * 4;
|
||||
for (int y = 0; y < 4; ++y) {
|
||||
RGBA8* target = targetMip + (baseY + y) * w + baseX;
|
||||
for (int x = 0; x < 4; ++x) {
|
||||
u16 texel = in.readUint16Big();
|
||||
if (texel & 0x8000) {
|
||||
target[x].r = Convert5To8(texel >> 10 & 0x1f);
|
||||
target[x].g = Convert5To8(texel >> 5 & 0x1f);
|
||||
int w = x4_w;
|
||||
int h = x6_h;
|
||||
RGBA8* targetMip = buf;
|
||||
for (u32 mip = 0; mip < x8_mips; ++mip) {
|
||||
int bwidth = (w + 3) / 4;
|
||||
int bheight = (h + 3) / 4;
|
||||
for (int by = 0; by < bheight; ++by) {
|
||||
int baseY = by * 4;
|
||||
for (int bx = 0; bx < bwidth; ++bx) {
|
||||
int baseX = bx * 4;
|
||||
for (int y = 0; y < 4; ++y) {
|
||||
RGBA8* target = targetMip + (baseY + y) * w + baseX;
|
||||
for (int x = 0; x < 4; ++x) {
|
||||
u16 texel = in.readUint16Big();
|
||||
target[x].r = Convert5To8(texel >> 11 & 0x1f);
|
||||
target[x].g = Convert6To8(texel >> 5 & 0x3f);
|
||||
target[x].b = Convert5To8(texel & 0x1f);
|
||||
target[x].a = 0xff;
|
||||
} else {
|
||||
target[x].r = Convert4To8(texel >> 8 & 0xf);
|
||||
target[x].g = Convert4To8(texel >> 4 & 0xf);
|
||||
target[x].b = Convert4To8(texel & 0xf);
|
||||
target[x].a = Convert3To8(texel >> 12 & 0x7);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
targetMip += w * h;
|
||||
if (w > 1)
|
||||
w /= 2;
|
||||
if (h > 1)
|
||||
h /= 2;
|
||||
}
|
||||
targetMip += w * h;
|
||||
if (w > 1)
|
||||
w /= 2;
|
||||
if (h > 1)
|
||||
h /= 2;
|
||||
}
|
||||
|
||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
||||
m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::RGBA8, boo::TextureClampMode::Repeat,
|
||||
buf.get(), texelCount * 4)
|
||||
.get();
|
||||
return true;
|
||||
} BooTrace);
|
||||
});
|
||||
}
|
||||
|
||||
void CTexture::BuildRGBA8FromGCN(CInputStream& in) {
|
||||
size_t texelCount = ComputeMippedTexelCount();
|
||||
std::unique_ptr<RGBA8[]> buf(new RGBA8[texelCount]);
|
||||
void CTexture::BuildRGB5A3FromGCN(CInputStream& in) {
|
||||
m_booTex = hsh::create_texture2d({x4_w, x6_h}, hsh::RGBA8_UNORM, x8_mips, [&](void* data, std::size_t size) {
|
||||
RGBA8* buf = reinterpret_cast<RGBA8*>(data);
|
||||
std::vector<RGBA8> palette = DecodePalette(256, in);
|
||||
|
||||
int w = x4_w;
|
||||
int h = x6_h;
|
||||
RGBA8* targetMip = buf.get();
|
||||
for (u32 mip = 0; mip < x8_mips; ++mip) {
|
||||
int bwidth = (w + 3) / 4;
|
||||
int bheight = (h + 3) / 4;
|
||||
for (int by = 0; by < bheight; ++by) {
|
||||
int baseY = by * 4;
|
||||
for (int bx = 0; bx < bwidth; ++bx) {
|
||||
int baseX = bx * 4;
|
||||
for (int c = 0; c < 2; ++c) {
|
||||
int w = x4_w;
|
||||
int h = x6_h;
|
||||
RGBA8* targetMip = buf;
|
||||
for (u32 mip = 0; mip < x8_mips; ++mip) {
|
||||
int bwidth = (w + 3) / 4;
|
||||
int bheight = (h + 3) / 4;
|
||||
for (int by = 0; by < bheight; ++by) {
|
||||
int baseY = by * 4;
|
||||
for (int bx = 0; bx < bwidth; ++bx) {
|
||||
int baseX = bx * 4;
|
||||
for (int y = 0; y < 4; ++y) {
|
||||
RGBA8* target = targetMip + (baseY + y) * w + baseX;
|
||||
u8 source[8];
|
||||
in.readBytesToBuf(source, 8);
|
||||
for (int x = 0; x < 4; ++x) {
|
||||
if (c) {
|
||||
target[x].g = source[x * 2];
|
||||
target[x].b = source[x * 2 + 1];
|
||||
u16 texel = in.readUint16Big();
|
||||
if (texel & 0x8000) {
|
||||
target[x].r = Convert5To8(texel >> 10 & 0x1f);
|
||||
target[x].g = Convert5To8(texel >> 5 & 0x1f);
|
||||
target[x].b = Convert5To8(texel & 0x1f);
|
||||
target[x].a = 0xff;
|
||||
} else {
|
||||
target[x].a = source[x * 2];
|
||||
target[x].r = source[x * 2 + 1];
|
||||
target[x].r = Convert4To8(texel >> 8 & 0xf);
|
||||
target[x].g = Convert4To8(texel >> 4 & 0xf);
|
||||
target[x].b = Convert4To8(texel & 0xf);
|
||||
target[x].a = Convert3To8(texel >> 12 & 0x7);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
targetMip += w * h;
|
||||
if (w > 1)
|
||||
w /= 2;
|
||||
if (h > 1)
|
||||
h /= 2;
|
||||
}
|
||||
targetMip += w * h;
|
||||
if (w > 1)
|
||||
w /= 2;
|
||||
if (h > 1)
|
||||
h /= 2;
|
||||
}
|
||||
|
||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
||||
m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::RGBA8, boo::TextureClampMode::Repeat,
|
||||
buf.get(), texelCount * 4)
|
||||
.get();
|
||||
return true;
|
||||
} BooTrace);
|
||||
});
|
||||
}
|
||||
|
||||
struct DXT1Block {
|
||||
uint16_t color1;
|
||||
uint16_t color2;
|
||||
uint8_t lines[4];
|
||||
};
|
||||
void CTexture::BuildRGBA8FromGCN(CInputStream& in) {
|
||||
m_booTex = hsh::create_texture2d({x4_w, x6_h}, hsh::RGBA8_UNORM, x8_mips, [&](void* data, std::size_t size) {
|
||||
RGBA8* buf = reinterpret_cast<RGBA8*>(data);
|
||||
std::vector<RGBA8> palette = DecodePalette(256, in);
|
||||
|
||||
void CTexture::BuildDXT1FromGCN(CInputStream& in) {
|
||||
size_t blockCount = ComputeMippedBlockCountDXT1();
|
||||
std::unique_ptr<DXT1Block[]> buf(new DXT1Block[blockCount]);
|
||||
|
||||
int w = x4_w / 4;
|
||||
int h = x6_h / 4;
|
||||
DXT1Block* targetMip = buf.get();
|
||||
for (u32 mip = 0; mip < x8_mips; ++mip) {
|
||||
int bwidth = (w + 1) / 2;
|
||||
int bheight = (h + 1) / 2;
|
||||
for (int by = 0; by < bheight; ++by) {
|
||||
int baseY = by * 2;
|
||||
for (int bx = 0; bx < bwidth; ++bx) {
|
||||
int baseX = bx * 2;
|
||||
for (int y = 0; y < 2; ++y) {
|
||||
DXT1Block* target = targetMip + (baseY + y) * w + baseX;
|
||||
DXT1Block source[2];
|
||||
in.readBytesToBuf(source, 16);
|
||||
for (int x = 0; x < 2; ++x) {
|
||||
target[x].color1 = hecl::SBig(source[x].color1);
|
||||
target[x].color2 = hecl::SBig(source[x].color2);
|
||||
for (u32 i = 0; i < 4; ++i) {
|
||||
u8 ind[4];
|
||||
u8 packed = source[x].lines[i];
|
||||
ind[3] = packed & 0x3;
|
||||
ind[2] = (packed >> 2) & 0x3;
|
||||
ind[1] = (packed >> 4) & 0x3;
|
||||
ind[0] = (packed >> 6) & 0x3;
|
||||
target[x].lines[i] = ind[0] | (ind[1] << 2) | (ind[2] << 4) | (ind[3] << 6);
|
||||
int w = x4_w;
|
||||
int h = x6_h;
|
||||
RGBA8* targetMip = buf;
|
||||
for (u32 mip = 0; mip < x8_mips; ++mip) {
|
||||
int bwidth = (w + 3) / 4;
|
||||
int bheight = (h + 3) / 4;
|
||||
for (int by = 0; by < bheight; ++by) {
|
||||
int baseY = by * 4;
|
||||
for (int bx = 0; bx < bwidth; ++bx) {
|
||||
int baseX = bx * 4;
|
||||
for (int c = 0; c < 2; ++c) {
|
||||
for (int y = 0; y < 4; ++y) {
|
||||
RGBA8* target = targetMip + (baseY + y) * w + baseX;
|
||||
u8 source[8];
|
||||
in.readBytesToBuf(source, 8);
|
||||
for (int x = 0; x < 4; ++x) {
|
||||
if (c) {
|
||||
target[x].g = source[x * 2];
|
||||
target[x].b = source[x * 2 + 1];
|
||||
} else {
|
||||
target[x].a = source[x * 2];
|
||||
target[x].r = source[x * 2 + 1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
targetMip += w * h;
|
||||
if (w > 1)
|
||||
w /= 2;
|
||||
if (h > 1)
|
||||
h /= 2;
|
||||
}
|
||||
targetMip += w * h;
|
||||
|
||||
if (w > 1)
|
||||
w /= 2;
|
||||
if (h > 1)
|
||||
h /= 2;
|
||||
}
|
||||
|
||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
||||
m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::DXT1, boo::TextureClampMode::Repeat,
|
||||
buf.get(), blockCount * 8)
|
||||
.get();
|
||||
return true;
|
||||
} BooTrace);
|
||||
});
|
||||
}
|
||||
|
||||
void CTexture::BuildRGBA8(const void* data, size_t length) {
|
||||
size_t texelCount = ComputeMippedTexelCount();
|
||||
size_t expectedSize = texelCount * 4;
|
||||
if (expectedSize > length)
|
||||
Log.report(logvisor::Fatal, FMT_STRING("insufficient TXTR length ({}/{})"), length, expectedSize);
|
||||
|
||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
||||
m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::RGBA8, boo::TextureClampMode::Repeat, data,
|
||||
expectedSize)
|
||||
.get();
|
||||
return true;
|
||||
} BooTrace);
|
||||
void CTexture::BuildRGBA8(const void* dataIn, size_t length) {
|
||||
m_booTex = hsh::create_texture2d({x4_w, x6_h}, hsh::RGBA8_UNORM, x8_mips, [&](void* data, std::size_t size) {
|
||||
std::memcpy(data, dataIn, length);
|
||||
});
|
||||
}
|
||||
|
||||
void CTexture::BuildC8(const void* data, size_t length) {
|
||||
size_t texelCount = ComputeMippedTexelCount();
|
||||
if (texelCount > length)
|
||||
Log.report(logvisor::Fatal, FMT_STRING("insufficient TXTR length ({}/{})"), length, texelCount);
|
||||
uint32_t nentries = hecl::SBig(*reinterpret_cast<const uint32_t*>(data));
|
||||
const u8* paletteTexels = reinterpret_cast<const u8*>(data) + 4;
|
||||
const u8* texels = reinterpret_cast<const u8*>(data) + 4 + nentries * 4;
|
||||
|
||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
||||
uint32_t nentries = hecl::SBig(*reinterpret_cast<const uint32_t*>(data));
|
||||
const u8* paletteTexels = reinterpret_cast<const u8*>(data) + 4;
|
||||
const u8* texels = reinterpret_cast<const u8*>(data) + 4 + nentries * 4;
|
||||
m_paletteTex = ctx.newStaticTexture(nentries, 1, 1, boo::TextureFormat::RGBA8, boo::TextureClampMode::Repeat,
|
||||
paletteTexels, nentries * 4)
|
||||
.get();
|
||||
m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::I8, boo::TextureClampMode::Repeat, texels,
|
||||
texelCount)
|
||||
.get();
|
||||
return true;
|
||||
} BooTrace);
|
||||
m_paletteTex = hsh::create_texture2d({nentries, 1}, hsh::RGBA8_UNORM, 1, [&](void* data, std::size_t size) {
|
||||
std::memcpy(data, paletteTexels, nentries * 4);
|
||||
});
|
||||
|
||||
m_booTex = hsh::create_texture2d({x4_w, x6_h}, hsh::R8_UNORM, x8_mips, [&](void* data, std::size_t size) {
|
||||
std::memcpy(data, texels, size);
|
||||
});
|
||||
}
|
||||
|
||||
void CTexture::BuildC8Font(const void* data, EFontType ftype) {
|
||||
|
@ -672,30 +548,21 @@ void CTexture::BuildC8Font(const void* data, EFontType ftype) {
|
|||
h /= 2;
|
||||
}
|
||||
|
||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
||||
m_booTex = ctx.newStaticArrayTexture(x4_w, x6_h, layerCount, x8_mips, boo::TextureFormat::RGBA8,
|
||||
boo::TextureClampMode::Repeat, buf.get(), texelCount * layerCount * 4)
|
||||
.get();
|
||||
return true;
|
||||
} BooTrace);
|
||||
m_booTex = hsh::create_texture2d_array({x4_w, x6_h}, layerCount, hsh::R8_UNORM, x8_mips, [&](void* data, std::size_t size) {
|
||||
std::memcpy(data, texels, size);
|
||||
});
|
||||
}
|
||||
|
||||
void CTexture::BuildDXT1(const void* data, size_t length) {
|
||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
||||
m_booTex =
|
||||
ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::DXT1, boo::TextureClampMode::Repeat, data, length)
|
||||
.get();
|
||||
return true;
|
||||
} BooTrace);
|
||||
void CTexture::BuildDXT1(const void* dataIn, size_t length) {
|
||||
m_booTex = hsh::create_texture2d({x4_w, x6_h}, hsh::BC1_UNORM, x8_mips, [&](void* data, std::size_t size) {
|
||||
std::memcpy(data, dataIn, size);
|
||||
});
|
||||
}
|
||||
|
||||
void CTexture::BuildDXT3(const void* data, size_t length) {
|
||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
||||
m_booTex =
|
||||
ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::DXT3, boo::TextureClampMode::Repeat, data, length)
|
||||
.get();
|
||||
return true;
|
||||
} BooTrace);
|
||||
void CTexture::BuildDXT3(const void* dataIn, size_t length) {
|
||||
m_booTex = hsh::create_texture2d({x4_w, x6_h}, hsh::BC2_UNORM, x8_mips, [&](void* data, std::size_t size) {
|
||||
std::memcpy(data, dataIn, size);
|
||||
});
|
||||
}
|
||||
|
||||
CTexture::CTexture(ETexelFormat fmt, s16 w, s16 h, s32 mips) : x0_fmt(fmt), x4_w(w), x6_h(h), x8_mips(mips) {
|
||||
|
@ -856,12 +723,12 @@ std::unique_ptr<u8[]> CTexture::BuildMemoryCardTex(u32& sizeOut, ETexelFormat& f
|
|||
return ret;
|
||||
}
|
||||
|
||||
const boo::ObjToken<boo::ITexture>& CTexture::GetFontTexture(EFontType tp) {
|
||||
hsh::texture_typeless CTexture::GetFontTexture(EFontType tp) {
|
||||
if (m_ftype != tp && x0_fmt == ETexelFormat::C8PC) {
|
||||
m_ftype = tp;
|
||||
BuildC8Font(m_otex.get() + 12, m_ftype);
|
||||
}
|
||||
return m_booTex;
|
||||
return m_booTex.get();
|
||||
}
|
||||
|
||||
CFactoryFnReturn FTextureFactory(const urde::SObjectTag& tag, std::unique_ptr<u8[]>&& in, u32 len,
|
||||
|
@ -869,7 +736,7 @@ CFactoryFnReturn FTextureFactory(const urde::SObjectTag& tag, std::unique_ptr<u8
|
|||
u32 u32Owned = vparms.GetOwnedObj<u32>();
|
||||
const CTextureInfo* inf = nullptr;
|
||||
if (g_TextureCache)
|
||||
inf = g_TextureCache->GetTextureInfo(tag.id);
|
||||
inf = g_TextureCache->GetTextureInfo(tag.id);
|
||||
return TToken<CTexture>::GetIObjObjectFor(
|
||||
std::make_unique<CTexture>(std::move(in), len, u32Owned == SBIG('OTEX'), inf));
|
||||
}
|
||||
|
|
|
@ -9,19 +9,6 @@
|
|||
|
||||
namespace urde {
|
||||
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_zOnlyPipeline;
|
||||
|
||||
void CAABoxShader::Initialize() {
|
||||
s_Pipeline = hecl::conv->convert(Shader_CAABoxShader{});
|
||||
s_zOnlyPipeline = hecl::conv->convert(Shader_CAABoxShaderZOnly{});
|
||||
}
|
||||
|
||||
void CAABoxShader::Shutdown() {
|
||||
s_Pipeline.reset();
|
||||
s_zOnlyPipeline.reset();
|
||||
}
|
||||
|
||||
CAABoxShader::CAABoxShader(bool zOnly) {
|
||||
CGraphics::CommitResources([this, zOnly](boo::IGraphicsDataFactory::Context& ctx) {
|
||||
m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(zeus::CVector3f), 34);
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
||||
|
||||
#include <zeus/CColor.hpp>
|
||||
#include <zeus/CMatrix4f.hpp>
|
||||
#include "zeus/CColor.hpp"
|
||||
#include "zeus/CMatrix4f.hpp"
|
||||
|
||||
namespace zeus {
|
||||
class CAABox;
|
||||
|
@ -12,18 +10,19 @@ class CAABox;
|
|||
namespace urde {
|
||||
|
||||
class CAABoxShader {
|
||||
struct Uniform {
|
||||
zeus::CMatrix4f m_xf;
|
||||
zeus::CColor m_color;
|
||||
struct Vert {
|
||||
hsh::float3 m_pos;
|
||||
};
|
||||
boo::ObjToken<boo::IGraphicsBufferD> m_vbo;
|
||||
boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
|
||||
boo::ObjToken<boo::IShaderDataBinding> m_dataBind;
|
||||
struct Uniform {
|
||||
hsh::float4x4 m_xf;
|
||||
hsh::float4 m_color;
|
||||
};
|
||||
hsh::owner<hsh::vertex_buffer<Vert>> m_vbo;
|
||||
hsh::dynamic_owner<hsh::uniform_buffer<Uniform>> m_uniBuf;
|
||||
hsh::binding m_dataBind;
|
||||
Uniform m_uniform;
|
||||
|
||||
public:
|
||||
static void Initialize();
|
||||
static void Shutdown();
|
||||
explicit CAABoxShader(bool zOnly = false);
|
||||
void setAABB(const zeus::CAABox& aabb);
|
||||
void draw(const zeus::CColor& color);
|
||||
|
|
|
@ -5,34 +5,32 @@
|
|||
|
||||
#include "Runtime/Graphics/CGraphics.hpp"
|
||||
|
||||
#include <hecl/Pipeline.hpp>
|
||||
#include <zeus/CVector2f.hpp>
|
||||
#include "CCameraBlurFilter.cpp.hshhead"
|
||||
|
||||
namespace urde {
|
||||
namespace {
|
||||
struct Vert {
|
||||
zeus::CVector2f m_pos;
|
||||
zeus::CVector2f m_uv;
|
||||
using namespace hsh::pipeline;
|
||||
|
||||
struct CCameraBlurFilterPipeline : pipeline<color_attachment<>> {
|
||||
CCameraBlurFilterPipeline(hsh::vertex_buffer<CCameraBlurFilter::Vert> vbo,
|
||||
hsh::uniform_buffer<CCameraBlurFilter::Uniform> ubo,
|
||||
hsh::render_texture2d tex) {
|
||||
position = hsh::float4(vbo->m_pos, 0.f, 1.f);
|
||||
|
||||
hsh::float4 colorSample = tex.sample<float>(vbo->m_uv) * 0.14285715f;
|
||||
colorSample += tex.sample<float>(vbo->m_uv + ubo->m_uv[0]) * 0.14285715f;
|
||||
colorSample += tex.sample<float>(vbo->m_uv + ubo->m_uv[1]) * 0.14285715f;
|
||||
colorSample += tex.sample<float>(vbo->m_uv + ubo->m_uv[2]) * 0.14285715f;
|
||||
colorSample += tex.sample<float>(vbo->m_uv + ubo->m_uv[3]) * 0.14285715f;
|
||||
colorSample += tex.sample<float>(vbo->m_uv + ubo->m_uv[4]) * 0.14285715f;
|
||||
colorSample += tex.sample<float>(vbo->m_uv + ubo->m_uv[5]) * 0.14285715f;
|
||||
color_out[0] = hsh::float4(colorSample.xyz(), ubo->m_opacity);
|
||||
}
|
||||
};
|
||||
|
||||
boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
|
||||
} // Anonymous namespace
|
||||
|
||||
void CCameraBlurFilter::Initialize() { s_Pipeline = hecl::conv->convert(Shader_CCameraBlurFilter{}); }
|
||||
|
||||
void CCameraBlurFilter::Shutdown() { s_Pipeline.reset(); }
|
||||
|
||||
CCameraBlurFilter::CCameraBlurFilter() {
|
||||
CGraphics::CommitResources([this](boo::IGraphicsDataFactory::Context& ctx) {
|
||||
m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, 32, 4);
|
||||
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
|
||||
boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {m_uniBuf.get()};
|
||||
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
|
||||
boo::ObjToken<boo::ITexture> texs[] = {CGraphics::g_SpareTexture.get()};
|
||||
m_dataBind = ctx.newShaderDataBinding(s_Pipeline, m_vbo.get(), nullptr, nullptr, 1, bufs, stages, nullptr, nullptr,
|
||||
1, texs, nullptr, nullptr);
|
||||
return true;
|
||||
} BooTrace);
|
||||
m_vbo = hsh::create_dynamic_vertex_buffer<Vert>(4);
|
||||
m_uniBuf = hsh::create_dynamic_uniform_buffer<Uniform>();
|
||||
m_dataBind.hsh_bind(CCameraBlurFilterPipeline(m_vbo.get(), m_uniBuf.get(), CGraphics::g_SpareTexture.get_color(0)));
|
||||
}
|
||||
|
||||
void CCameraBlurFilter::draw(float amount, bool clearDepth) {
|
||||
|
@ -55,7 +53,7 @@ void CCameraBlurFilter::draw(float amount, bool clearDepth) {
|
|||
{{1.0, -1.0}, {xBias + xFac, yBias}},
|
||||
{{1.0, 1.0}, {xBias + xFac, yBias + yFac}},
|
||||
};
|
||||
m_vbo->load(verts, sizeof(verts));
|
||||
m_vbo.load(verts);
|
||||
|
||||
for (int i = 0; i < 6; ++i) {
|
||||
float tmp = i;
|
||||
|
@ -68,14 +66,12 @@ void CCameraBlurFilter::draw(float amount, bool clearDepth) {
|
|||
float amtY = std::sin(tmp);
|
||||
amtY *= amount / 448.f;
|
||||
|
||||
m_uniform.m_uv[i][0] = amtX * xFac;
|
||||
m_uniform.m_uv[i][1] = amtY * yFac;
|
||||
m_uniform.m_uv[i].x = amtX * xFac;
|
||||
m_uniform.m_uv[i].y = amtY * yFac;
|
||||
}
|
||||
m_uniform.m_opacity = std::min(amount / 2.f, 1.f);
|
||||
m_uniBuf->load(&m_uniform, sizeof(m_uniform));
|
||||
|
||||
CGraphics::SetShaderDataBinding(m_dataBind);
|
||||
CGraphics::DrawArray(0, 4);
|
||||
m_uniBuf.load(m_uniform);
|
||||
m_dataBind.draw(0, 4);
|
||||
}
|
||||
|
||||
} // namespace urde
|
||||
|
|
|
@ -1,24 +1,27 @@
|
|||
#pragma once
|
||||
|
||||
#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
||||
#include <zeus/CVector4f.hpp>
|
||||
#include "hsh/hsh.h"
|
||||
#include "zeus/CVector4f.hpp"
|
||||
|
||||
namespace urde {
|
||||
|
||||
class CCameraBlurFilter {
|
||||
friend struct CCameraBlurFilterPipeline;
|
||||
struct Vert {
|
||||
hsh::float2 m_pos;
|
||||
hsh::float2 m_uv;
|
||||
};
|
||||
struct Uniform {
|
||||
zeus::CVector4f m_uv[6];
|
||||
hsh::aligned_array<hsh::float2, 6> m_uv;
|
||||
float m_opacity = 1.f;
|
||||
};
|
||||
|
||||
boo::ObjToken<boo::IGraphicsBufferD> m_vbo;
|
||||
boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
|
||||
boo::ObjToken<boo::IShaderDataBinding> m_dataBind;
|
||||
hsh::dynamic_owner<hsh::vertex_buffer<Vert>> m_vbo;
|
||||
hsh::dynamic_owner<hsh::uniform_buffer<Uniform>> m_uniBuf;
|
||||
hsh::binding m_dataBind;
|
||||
Uniform m_uniform;
|
||||
|
||||
public:
|
||||
static void Initialize();
|
||||
static void Shutdown();
|
||||
CCameraBlurFilter();
|
||||
void draw(float amount, bool clearDepth = false);
|
||||
};
|
||||
|
|
|
@ -5,61 +5,32 @@
|
|||
#include "Runtime/Camera/CCameraFilter.hpp"
|
||||
#include "Runtime/Graphics/CGraphics.hpp"
|
||||
|
||||
#include <hecl/Pipeline.hpp>
|
||||
#include "CColoredQuadFilter.cpp.hshhead"
|
||||
|
||||
namespace urde {
|
||||
using namespace hsh::pipeline;
|
||||
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_AlphaPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_AddPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_MultPipeline;
|
||||
|
||||
void CColoredQuadFilter::Initialize() {
|
||||
s_AlphaPipeline = hecl::conv->convert(Shader_CColoredQuadFilter{});
|
||||
s_AddPipeline = hecl::conv->convert(Shader_CColoredQuadFilterAdd{});
|
||||
s_MultPipeline = hecl::conv->convert(Shader_CColoredQuadFilterMul{});
|
||||
}
|
||||
|
||||
void CColoredQuadFilter::Shutdown() {
|
||||
s_AlphaPipeline.reset();
|
||||
s_AddPipeline.reset();
|
||||
s_MultPipeline.reset();
|
||||
}
|
||||
|
||||
static boo::ObjToken<boo::IShaderPipeline> SelectPipeline(EFilterType type) {
|
||||
switch (type) {
|
||||
case EFilterType::Blend:
|
||||
return s_AlphaPipeline;
|
||||
case EFilterType::Add:
|
||||
return s_AddPipeline;
|
||||
case EFilterType::Multiply:
|
||||
return s_MultPipeline;
|
||||
default:
|
||||
return {};
|
||||
template <EFilterType Type>
|
||||
struct CColoredQuadFilterPipeline : FilterPipeline<Type> {
|
||||
CColoredQuadFilterPipeline(hsh::vertex_buffer<CColoredQuadFilter::Vert> vbo,
|
||||
hsh::uniform_buffer<CColoredQuadFilter::Uniform> uniBuf) {
|
||||
this->position = hsh::float4(vbo->m_pos, 1.f);
|
||||
this->color_out[0] = uniBuf->m_color;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
CColoredQuadFilter::CColoredQuadFilter(EFilterType type) {
|
||||
CGraphics::CommitResources([this, type](boo::IGraphicsDataFactory::Context& ctx) {
|
||||
struct Vert {
|
||||
zeus::CVector2f m_pos;
|
||||
};
|
||||
constexpr std::array<Vert, 4> verts{{
|
||||
{{0.f, 0.f, 0.f}},
|
||||
{{0.f, 1.f, 0.f}},
|
||||
{{1.f, 0.f, 0.f}},
|
||||
{{1.f, 1.f, 0.f}},
|
||||
}};
|
||||
|
||||
const std::array<Vert, 4> verts{{
|
||||
{{0.0, 0.0}},
|
||||
{{0.0, 1.0}},
|
||||
{{1.0, 0.0}},
|
||||
{{1.0, 1.0}},
|
||||
}};
|
||||
m_vbo = hsh::create_vertex_buffer(verts);
|
||||
m_uniBuf = hsh::create_dynamic_uniform_buffer<Uniform>();
|
||||
|
||||
m_vbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, verts.data(), 16, verts.size());
|
||||
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
|
||||
|
||||
const std::array<boo::ObjToken<boo::IGraphicsBuffer>, 1> bufs{m_uniBuf.get()};
|
||||
constexpr std::array<boo::PipelineStage, 1> stages{boo::PipelineStage::Vertex};
|
||||
m_dataBind = ctx.newShaderDataBinding(SelectPipeline(type), m_vbo.get(), nullptr, nullptr, bufs.size(), bufs.data(),
|
||||
stages.data(), nullptr, nullptr, 0, nullptr, nullptr, nullptr);
|
||||
return true;
|
||||
} BooTrace);
|
||||
m_dataBind.hsh_bind(CColoredQuadFilterPipeline<type>(m_vbo.get(), m_uniBuf.get()));
|
||||
}
|
||||
|
||||
void CColoredQuadFilter::draw(const zeus::CColor& color, const zeus::CRectangle& rect) {
|
||||
|
@ -70,10 +41,9 @@ void CColoredQuadFilter::draw(const zeus::CColor& color, const zeus::CRectangle&
|
|||
m_uniform.m_matrix[3][0] = rect.position.x() * 2.f - 1.f;
|
||||
m_uniform.m_matrix[3][1] = rect.position.y() * 2.f - 1.f;
|
||||
m_uniform.m_color = color;
|
||||
m_uniBuf->load(&m_uniform, sizeof(m_uniform));
|
||||
m_uniBuf.load(m_uniform);
|
||||
|
||||
CGraphics::SetShaderDataBinding(m_dataBind);
|
||||
CGraphics::DrawArray(0, 4);
|
||||
m_dataBind.draw(0, 4);
|
||||
}
|
||||
|
||||
void CWideScreenFilter::draw(const zeus::CColor& color, float t) {
|
||||
|
@ -94,12 +64,12 @@ float CWideScreenFilter::SetViewportToMatch(float t) {
|
|||
if (g_Viewport.aspect < 1.7777f) {
|
||||
float targetHeight = g_Viewport.x8_width / 1.7777f;
|
||||
float delta = (g_Viewport.xc_height - targetHeight) * t / 2.f;
|
||||
boo::SWindowRect rect = {};
|
||||
rect.size[0] = g_Viewport.x8_width;
|
||||
rect.size[1] = g_Viewport.xc_height - delta * 2.f;
|
||||
rect.location[1] = delta;
|
||||
hsh::viewport rect{};
|
||||
rect.width = g_Viewport.x8_width;
|
||||
rect.height = g_Viewport.xc_height - delta * 2.f;
|
||||
rect.y = delta;
|
||||
CGraphics::g_CroppedViewport = rect;
|
||||
CGraphics::g_BooMainCommandQueue->setViewport(rect);
|
||||
CGraphics::g_SpareTexture.attach(rect);
|
||||
return 1.7777f;
|
||||
} else {
|
||||
SetViewportToFull();
|
||||
|
@ -108,11 +78,11 @@ float CWideScreenFilter::SetViewportToMatch(float t) {
|
|||
}
|
||||
|
||||
void CWideScreenFilter::SetViewportToFull() {
|
||||
boo::SWindowRect rect = {};
|
||||
rect.size[0] = g_Viewport.x8_width;
|
||||
rect.size[1] = g_Viewport.xc_height;
|
||||
hsh::viewport rect{};
|
||||
rect.width = g_Viewport.x8_width;
|
||||
rect.height = g_Viewport.xc_height;
|
||||
CGraphics::g_CroppedViewport = rect;
|
||||
CGraphics::g_BooMainCommandQueue->setViewport(rect);
|
||||
CGraphics::g_SpareTexture.attach(rect);
|
||||
}
|
||||
|
||||
const zeus::CRectangle CColoredQuadFilter::DefaultRect = {0.f, 0.f, 1.f, 1.f};
|
||||
|
|
|
@ -2,11 +2,9 @@
|
|||
|
||||
#include "Runtime/CToken.hpp"
|
||||
|
||||
#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
||||
|
||||
#include <zeus/CColor.hpp>
|
||||
#include <zeus/CMatrix4f.hpp>
|
||||
#include <zeus/CRectangle.hpp>
|
||||
#include "zeus/CColor.hpp"
|
||||
#include "zeus/CMatrix4f.hpp"
|
||||
#include "zeus/CRectangle.hpp"
|
||||
|
||||
namespace urde {
|
||||
class CTexture;
|
||||
|
@ -15,18 +13,21 @@ enum class EFilterShape;
|
|||
enum class EFilterType;
|
||||
|
||||
class CColoredQuadFilter {
|
||||
template <EFilterType Type>
|
||||
friend struct CColoredQuadFilterPipeline;
|
||||
struct Uniform {
|
||||
zeus::CMatrix4f m_matrix;
|
||||
zeus::CColor m_color;
|
||||
hsh::float4x4 m_matrix;
|
||||
hsh::float4 m_color;
|
||||
};
|
||||
boo::ObjToken<boo::IGraphicsBufferS> m_vbo;
|
||||
boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
|
||||
boo::ObjToken<boo::IShaderDataBinding> m_dataBind;
|
||||
struct Vert {
|
||||
hsh::float3 m_pos;
|
||||
};
|
||||
hsh::owner<hsh::vertex_buffer<Vert>> m_vbo;
|
||||
hsh::dynamic_owner<hsh::uniform_buffer<Uniform>> m_uniBuf;
|
||||
hsh::binding m_dataBind;
|
||||
Uniform m_uniform;
|
||||
|
||||
public:
|
||||
static void Initialize();
|
||||
static void Shutdown();
|
||||
static const zeus::CRectangle DefaultRect;
|
||||
explicit CColoredQuadFilter(EFilterType type);
|
||||
explicit CColoredQuadFilter(EFilterType type, const TLockedToken<CTexture>&) : CColoredQuadFilter(type) {}
|
||||
|
|
|
@ -6,29 +6,8 @@
|
|||
#include "Runtime/Graphics/CBooRenderer.hpp"
|
||||
#include "Runtime/Graphics/CGraphics.hpp"
|
||||
|
||||
#include <hecl/Pipeline.hpp>
|
||||
|
||||
namespace urde {
|
||||
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_AdditivePipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_FullAdditivePipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_SubtractivePipeline;
|
||||
|
||||
void CColoredStripShader::Initialize() {
|
||||
s_Pipeline = hecl::conv->convert(Shader_CColoredStripShader{});
|
||||
s_AdditivePipeline = hecl::conv->convert(Shader_CColoredStripShaderAdditive{});
|
||||
s_FullAdditivePipeline = hecl::conv->convert(Shader_CColoredStripShaderFullAdditive{});
|
||||
s_SubtractivePipeline = hecl::conv->convert(Shader_CColoredStripShaderSubtractive{});
|
||||
}
|
||||
|
||||
void CColoredStripShader::Shutdown() {
|
||||
s_Pipeline.reset();
|
||||
s_AdditivePipeline.reset();
|
||||
s_FullAdditivePipeline.reset();
|
||||
s_SubtractivePipeline.reset();
|
||||
}
|
||||
|
||||
static const boo::ObjToken<boo::IShaderPipeline>& SelectPipeline(CColoredStripShader::Mode mode) {
|
||||
switch (mode) {
|
||||
case CColoredStripShader::Mode::Alpha:
|
||||
|
|
|
@ -1,12 +1,9 @@
|
|||
#pragma once
|
||||
|
||||
#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
||||
#include "zeus/CColor.hpp"
|
||||
#include "zeus/CMatrix4f.hpp"
|
||||
|
||||
#include <zeus/CColor.hpp>
|
||||
#include <zeus/CMatrix4f.hpp>
|
||||
|
||||
namespace urde
|
||||
{
|
||||
namespace urde {
|
||||
|
||||
class CColoredStripShader {
|
||||
public:
|
||||
|
@ -16,29 +13,24 @@ public:
|
|||
FullAdditive,
|
||||
Subtractive
|
||||
};
|
||||
private:
|
||||
struct Uniform {
|
||||
zeus::CMatrix4f m_matrix;
|
||||
zeus::CColor m_color;
|
||||
};
|
||||
boo::ObjToken<boo::IGraphicsBufferD> m_vbo;
|
||||
boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
|
||||
boo::ObjToken<boo::IShaderDataBinding> m_dataBind;
|
||||
Uniform m_uniform;
|
||||
|
||||
void BuildResources(boo::IGraphicsDataFactory::Context& ctx, size_t maxVerts, Mode mode,
|
||||
boo::ObjToken<boo::ITexture> tex);
|
||||
public:
|
||||
struct Vert {
|
||||
zeus::CVector3f m_pos;
|
||||
zeus::CColor m_color;
|
||||
zeus::CVector2f m_uv;
|
||||
};
|
||||
static void Initialize();
|
||||
static void Shutdown();
|
||||
CColoredStripShader(size_t maxVerts, Mode mode, boo::ObjToken<boo::ITexture> tex);
|
||||
CColoredStripShader(boo::IGraphicsDataFactory::Context& ctx, size_t maxVerts, Mode mode,
|
||||
boo::ObjToken<boo::ITexture> tex);
|
||||
|
||||
private:
|
||||
struct Uniform {
|
||||
zeus::CMatrix4f m_matrix;
|
||||
zeus::CColor m_color;
|
||||
};
|
||||
hsh::dynamic_owner<hsh::vertex_buffer<Vert>> m_vbo;
|
||||
hsh::dynamic_owner<hsh::uniform_buffer<Uniform>> m_uniBuf;
|
||||
hsh::binding m_dataBind;
|
||||
Uniform m_uniform;
|
||||
|
||||
public:
|
||||
CColoredStripShader(size_t maxVerts, Mode mode, hsh::texture2d tex);
|
||||
void draw(const zeus::CColor& color, size_t numVerts, const Vert* verts);
|
||||
};
|
||||
|
||||
|
|
|
@ -1,50 +1,18 @@
|
|||
#pragma once
|
||||
|
||||
#include <array>
|
||||
|
||||
#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
||||
#include "hsh/hsh.h"
|
||||
|
||||
namespace urde {
|
||||
class CElementGen;
|
||||
|
||||
class CElementGenShaders {
|
||||
hsh::binding m_shaderBind;
|
||||
public:
|
||||
enum class EShaderClass { Tex, IndTex, NoTex };
|
||||
|
||||
private:
|
||||
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texZTestZWrite;
|
||||
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texNoZTestZWrite;
|
||||
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texZTestNoZWrite;
|
||||
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texNoZTestNoZWrite;
|
||||
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texAdditiveZTest;
|
||||
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texAdditiveNoZTest;
|
||||
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texRedToAlphaZTest;
|
||||
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texRedToAlphaNoZTest;
|
||||
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texZTestNoZWriteSub;
|
||||
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texNoZTestNoZWriteSub;
|
||||
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texRedToAlphaZTestSub;
|
||||
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texRedToAlphaNoZTestSub;
|
||||
|
||||
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_indTexZWrite;
|
||||
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_indTexNoZWrite;
|
||||
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_indTexAdditive;
|
||||
|
||||
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_cindTexZWrite;
|
||||
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_cindTexNoZWrite;
|
||||
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_cindTexAdditive;
|
||||
|
||||
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_noTexZTestZWrite;
|
||||
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_noTexNoZTestZWrite;
|
||||
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_noTexZTestNoZWrite;
|
||||
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_noTexNoZTestNoZWrite;
|
||||
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_noTexAdditiveZTest;
|
||||
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_noTexAdditiveNoZTest;
|
||||
|
||||
public:
|
||||
static void Initialize();
|
||||
static void Shutdown();
|
||||
static EShaderClass GetShaderClass(CElementGen& gen);
|
||||
static void BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, CElementGen& gen);
|
||||
hsh::binding& BuildShaderDataBinding(CElementGen& gen);
|
||||
};
|
||||
|
||||
} // namespace urde
|
||||
|
|
|
@ -5,16 +5,8 @@
|
|||
#include "Runtime/Graphics/CGraphics.hpp"
|
||||
#include "Runtime/Graphics/CTexture.hpp"
|
||||
|
||||
#include <hecl/Pipeline.hpp>
|
||||
|
||||
namespace urde {
|
||||
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
|
||||
|
||||
void CEnergyBarShader::Initialize() { s_Pipeline = hecl::conv->convert(Shader_CEnergyBarShader{}); }
|
||||
|
||||
void CEnergyBarShader::Shutdown() { s_Pipeline.reset(); }
|
||||
|
||||
void CEnergyBarShader::updateModelMatrix() {
|
||||
m_uniform.m_matrix = CGraphics::GetPerspectiveProjectionMatrix(true) * CGraphics::g_GXModelView.toMatrix4f();
|
||||
}
|
||||
|
|
|
@ -3,12 +3,10 @@
|
|||
#include <array>
|
||||
#include <vector>
|
||||
|
||||
#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
||||
|
||||
#include <zeus/CColor.hpp>
|
||||
#include <zeus/CMatrix4f.hpp>
|
||||
#include <zeus/CVector2f.hpp>
|
||||
#include <zeus/CVector3f.hpp>
|
||||
#include "zeus/CColor.hpp"
|
||||
#include "zeus/CMatrix4f.hpp"
|
||||
#include "zeus/CVector2f.hpp"
|
||||
#include "zeus/CVector3f.hpp"
|
||||
|
||||
namespace urde {
|
||||
class CTexture;
|
||||
|
@ -25,16 +23,14 @@ private:
|
|||
zeus::CMatrix4f m_matrix;
|
||||
zeus::CColor m_color;
|
||||
};
|
||||
boo::ObjToken<boo::IGraphicsBufferD> m_vbo;
|
||||
std::array<boo::ObjToken<boo::IGraphicsBufferD>, 3> m_uniBuf;
|
||||
std::array<boo::ObjToken<boo::IShaderDataBinding>, 3> m_dataBind;
|
||||
hsh::dynamic_owner<hsh::vertex_buffer<Vertex>> m_vbo;
|
||||
std::array<hsh::dynamic_owner<hsh::uniform_buffer<Uniform>>, 3> m_uniBuf;
|
||||
std::array<hsh::binding, 3> m_dataBind;
|
||||
Uniform m_uniform;
|
||||
const CTexture* m_tex = nullptr;
|
||||
size_t m_maxVerts = 0;
|
||||
|
||||
public:
|
||||
static void Initialize();
|
||||
static void Shutdown();
|
||||
void updateModelMatrix();
|
||||
void draw(const zeus::CColor& color0, const std::vector<Vertex>& verts0, const zeus::CColor& color1,
|
||||
const std::vector<Vertex>& verts1, const zeus::CColor& color2, const std::vector<Vertex>& verts2,
|
||||
|
|
|
@ -5,18 +5,6 @@
|
|||
#include <hecl/Pipeline.hpp>
|
||||
|
||||
namespace urde {
|
||||
boo::ObjToken<boo::IShaderPipeline> CEnvFxShaders::m_snowPipeline;
|
||||
boo::ObjToken<boo::IShaderPipeline> CEnvFxShaders::m_underwaterPipeline;
|
||||
|
||||
void CEnvFxShaders::Initialize() {
|
||||
m_snowPipeline = hecl::conv->convert(Shader_CEnvFxSnowShader{});
|
||||
m_underwaterPipeline = hecl::conv->convert(Shader_CEnvFxUnderwaterShader{});
|
||||
}
|
||||
|
||||
void CEnvFxShaders::Shutdown() {
|
||||
m_snowPipeline.reset();
|
||||
m_underwaterPipeline.reset();
|
||||
}
|
||||
|
||||
void CEnvFxShaders::BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, CEnvFxManager& fxMgr,
|
||||
CEnvFxManagerGrid& grid) {
|
||||
|
|
|
@ -2,13 +2,6 @@
|
|||
|
||||
#include <array>
|
||||
|
||||
#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
||||
|
||||
#include <zeus/CColor.hpp>
|
||||
#include <zeus/CMatrix4f.hpp>
|
||||
#include <zeus/CVector2f.hpp>
|
||||
#include <zeus/CVector3f.hpp>
|
||||
|
||||
namespace urde {
|
||||
class CEnvFxManager;
|
||||
class CEnvFxManagerGrid;
|
||||
|
@ -16,25 +9,18 @@ class CEnvFxManagerGrid;
|
|||
class CEnvFxShaders {
|
||||
public:
|
||||
struct Instance {
|
||||
std::array<zeus::CVector3f, 4> positions;
|
||||
zeus::CColor color;
|
||||
std::array<zeus::CVector2f, 4> uvs;
|
||||
std::array<hsh::float3, 4> positions;
|
||||
hsh::float4 color;
|
||||
std::array<hsh::float2, 4> uvs;
|
||||
};
|
||||
struct Uniform {
|
||||
zeus::CMatrix4f mv;
|
||||
zeus::CMatrix4f proj;
|
||||
zeus::CMatrix4f envMtx;
|
||||
zeus::CColor moduColor;
|
||||
hsh::float4x4 mv;
|
||||
hsh::float4x4 proj;
|
||||
hsh::float4x4 envMtx;
|
||||
hsh::float4 moduColor;
|
||||
};
|
||||
|
||||
private:
|
||||
static boo::ObjToken<boo::IShaderPipeline> m_snowPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> m_underwaterPipeline;
|
||||
|
||||
public:
|
||||
static void Initialize();
|
||||
static void Shutdown();
|
||||
static void BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, CEnvFxManager& fxMgr,
|
||||
static void BuildShaderDataBinding(CEnvFxManager& fxMgr,
|
||||
CEnvFxManagerGrid& grid);
|
||||
};
|
||||
|
||||
|
|
|
@ -3,124 +3,8 @@
|
|||
#include "Runtime/World/CRipple.hpp"
|
||||
#include "Runtime/World/CRippleManager.hpp"
|
||||
|
||||
#include <hecl/Pipeline.hpp>
|
||||
|
||||
namespace urde {
|
||||
|
||||
CFluidPlaneShader::Cache CFluidPlaneShader::_cache = {};
|
||||
|
||||
u16 CFluidPlaneShader::Cache::MakeCacheKey(const SFluidPlaneShaderInfo& info) {
|
||||
u16 ret = 0;
|
||||
|
||||
switch (info.m_type) {
|
||||
case EFluidType::NormalWater:
|
||||
case EFluidType::PhazonFluid:
|
||||
case EFluidType::Four:
|
||||
if (info.m_hasLightmap) {
|
||||
ret |= 1 << 2;
|
||||
if (info.m_doubleLightmapBlend)
|
||||
ret |= 1 << 3;
|
||||
}
|
||||
|
||||
if (!info.m_hasEnvMap && info.m_hasEnvBumpMap)
|
||||
ret |= 1 << 4;
|
||||
|
||||
if (info.m_hasEnvMap)
|
||||
ret |= 1 << 5;
|
||||
|
||||
break;
|
||||
|
||||
case EFluidType::PoisonWater:
|
||||
ret |= 1;
|
||||
|
||||
if (info.m_hasLightmap) {
|
||||
ret |= 1 << 2;
|
||||
if (info.m_doubleLightmapBlend)
|
||||
ret |= 1 << 3;
|
||||
}
|
||||
|
||||
if (info.m_hasEnvBumpMap)
|
||||
ret |= 1 << 4;
|
||||
|
||||
break;
|
||||
|
||||
case EFluidType::Lava:
|
||||
ret |= 2;
|
||||
|
||||
if (info.m_hasBumpMap)
|
||||
ret |= 1 << 2;
|
||||
|
||||
break;
|
||||
|
||||
case EFluidType::ThickLava:
|
||||
ret |= 3;
|
||||
|
||||
if (info.m_hasBumpMap)
|
||||
ret |= 1 << 2;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (info.m_hasPatternTex1)
|
||||
ret |= 1 << 6;
|
||||
if (info.m_hasPatternTex2)
|
||||
ret |= 1 << 7;
|
||||
if (info.m_hasColorTex)
|
||||
ret |= 1 << 8;
|
||||
|
||||
if (info.m_additive)
|
||||
ret |= 1 << 9;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
u16 CFluidPlaneShader::Cache::MakeCacheKey(const SFluidPlaneDoorShaderInfo& info) {
|
||||
u16 ret = 0;
|
||||
|
||||
if (info.m_hasPatternTex1)
|
||||
ret |= 1 << 0;
|
||||
if (info.m_hasPatternTex2)
|
||||
ret |= 1 << 1;
|
||||
if (info.m_hasColorTex)
|
||||
ret |= 1 << 2;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
template <>
|
||||
CFluidPlaneShader::ShaderPair
|
||||
CFluidPlaneShader::Cache::GetOrBuildShader<SFluidPlaneShaderInfo>(const SFluidPlaneShaderInfo& info) {
|
||||
u16 key = MakeCacheKey(info);
|
||||
auto& slot = CacheSlot(info, key);
|
||||
if (slot.m_regular)
|
||||
return slot;
|
||||
|
||||
slot.m_regular = hecl::conv->convert(Shader_CFluidPlaneShader{info, false});
|
||||
if (info.m_tessellation)
|
||||
slot.m_tessellation = hecl::conv->convert(Shader_CFluidPlaneShader{info, true});
|
||||
|
||||
return slot;
|
||||
}
|
||||
template <>
|
||||
CFluidPlaneShader::ShaderPair
|
||||
CFluidPlaneShader::Cache::GetOrBuildShader<SFluidPlaneDoorShaderInfo>(const SFluidPlaneDoorShaderInfo& info) {
|
||||
u16 key = MakeCacheKey(info);
|
||||
auto& slot = CacheSlot(info, key);
|
||||
if (slot.m_regular)
|
||||
return slot;
|
||||
|
||||
slot.m_regular = hecl::conv->convert(Shader_CFluidPlaneDoorShader{info});
|
||||
|
||||
return slot;
|
||||
}
|
||||
|
||||
void CFluidPlaneShader::Cache::Clear() {
|
||||
for (auto& p : m_cache)
|
||||
p.reset();
|
||||
for (auto& p : m_doorCache)
|
||||
p.reset();
|
||||
}
|
||||
|
||||
void CFluidPlaneShader::PrepareBinding(u32 maxVertCount) {
|
||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
||||
m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(Vertex), maxVertCount);
|
||||
|
@ -188,8 +72,6 @@ void CFluidPlaneShader::PrepareBinding(u32 maxVertCount) {
|
|||
} BooTrace);
|
||||
}
|
||||
|
||||
void CFluidPlaneShader::Shutdown() { _cache.Clear(); }
|
||||
|
||||
CFluidPlaneShader::CFluidPlaneShader(EFluidType type, const TLockedToken<CTexture>& patternTex1,
|
||||
const TLockedToken<CTexture>& patternTex2, const TLockedToken<CTexture>& colorTex,
|
||||
const TLockedToken<CTexture>& bumpMap, const TLockedToken<CTexture>& envMap,
|
||||
|
|
|
@ -8,17 +8,15 @@
|
|||
#include "Runtime/Graphics/Shaders/CModelShaders.hpp"
|
||||
#include "Runtime/World/CFluidPlaneManager.hpp"
|
||||
|
||||
#include "Shaders/shader_CFluidPlaneShader.hpp"
|
||||
|
||||
#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
||||
|
||||
#include <zeus/CColor.hpp>
|
||||
#include <zeus/CMatrix4f.hpp>
|
||||
#include <zeus/CVector3f.hpp>
|
||||
#include <zeus/CVector4f.hpp>
|
||||
#include "zeus/CColor.hpp"
|
||||
#include "zeus/CMatrix4f.hpp"
|
||||
#include "zeus/CVector3f.hpp"
|
||||
#include "zeus/CVector4f.hpp"
|
||||
|
||||
namespace urde {
|
||||
|
||||
enum class EFluidType { NormalWater, PoisonWater, Lava, PhazonFluid, Four, ThickLava };
|
||||
|
||||
class CFluidPlaneShader {
|
||||
public:
|
||||
struct Vertex {
|
||||
|
@ -53,35 +51,10 @@ public:
|
|||
};
|
||||
|
||||
private:
|
||||
struct ShaderPair {
|
||||
boo::ObjToken<boo::IShaderPipeline> m_regular;
|
||||
boo::ObjToken<boo::IShaderPipeline> m_tessellation;
|
||||
void reset() {
|
||||
m_regular.reset();
|
||||
m_tessellation.reset();
|
||||
}
|
||||
};
|
||||
|
||||
struct BindingPair {
|
||||
boo::ObjToken<boo::IShaderDataBinding> m_regular;
|
||||
boo::ObjToken<boo::IShaderDataBinding> m_tessellation;
|
||||
hsh::binding m_regular, m_tessellation;
|
||||
};
|
||||
|
||||
class Cache {
|
||||
std::array<ShaderPair, 1024> m_cache{};
|
||||
std::array<ShaderPair, 8> m_doorCache{};
|
||||
ShaderPair& CacheSlot(const SFluidPlaneShaderInfo& info, int i) { return m_cache[i]; }
|
||||
ShaderPair& CacheSlot(const SFluidPlaneDoorShaderInfo& info, int i) { return m_doorCache[i]; }
|
||||
static u16 MakeCacheKey(const SFluidPlaneShaderInfo& info);
|
||||
static u16 MakeCacheKey(const SFluidPlaneDoorShaderInfo& info);
|
||||
|
||||
public:
|
||||
template <class T>
|
||||
ShaderPair GetOrBuildShader(const T& info);
|
||||
void Clear();
|
||||
};
|
||||
static Cache _cache;
|
||||
|
||||
struct Ripple {
|
||||
zeus::CVector4f center; // time, distFalloff
|
||||
zeus::CVector4f params; // amplitude, lookupPhase, lookupTime
|
||||
|
@ -106,37 +79,11 @@ private:
|
|||
TLockedToken<CTexture> m_envMap;
|
||||
TLockedToken<CTexture> m_envBumpMap;
|
||||
TLockedToken<CTexture> m_lightmap;
|
||||
boo::ObjToken<boo::ITextureS> m_rippleMap;
|
||||
boo::ObjToken<boo::IGraphicsBufferD> m_vbo;
|
||||
boo::ObjToken<boo::IGraphicsBufferD> m_pvbo;
|
||||
boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
|
||||
ShaderPair m_pipelines;
|
||||
hsh::texture2d m_rippleMap;
|
||||
hsh::dynamic_owner<hsh::vertex_buffer<Vertex>> m_vbo;
|
||||
hsh::dynamic_owner<hsh::vertex_buffer<PatchVertex>> m_pvbo;
|
||||
hsh::dynamic_owner<hsh::uniform_buffer<Uniform>> m_uniBuf;
|
||||
BindingPair m_dataBind;
|
||||
int m_lastBind = -1;
|
||||
|
||||
#if BOO_HAS_GL
|
||||
static ShaderPair BuildShader(boo::GLDataFactory::Context& ctx, const SFluidPlaneShaderInfo& info);
|
||||
static ShaderPair BuildShader(boo::GLDataFactory::Context& ctx, const SFluidPlaneDoorShaderInfo& info);
|
||||
BindingPair BuildBinding(boo::GLDataFactory::Context& ctx, const ShaderPair& pipeline);
|
||||
#endif
|
||||
#if _WIN32
|
||||
static ShaderPair BuildShader(boo::D3D11DataFactory::Context& ctx, const SFluidPlaneShaderInfo& info);
|
||||
static ShaderPair BuildShader(boo::D3D11DataFactory::Context& ctx, const SFluidPlaneDoorShaderInfo& info);
|
||||
BindingPair BuildBinding(boo::D3D11DataFactory::Context& ctx, const ShaderPair& pipeline);
|
||||
#endif
|
||||
#if BOO_HAS_METAL
|
||||
static ShaderPair BuildShader(boo::MetalDataFactory::Context& ctx, const SFluidPlaneShaderInfo& info);
|
||||
static ShaderPair BuildShader(boo::MetalDataFactory::Context& ctx, const SFluidPlaneDoorShaderInfo& info);
|
||||
BindingPair BuildBinding(boo::MetalDataFactory::Context& ctx, const ShaderPair& pipeline);
|
||||
#endif
|
||||
#if BOO_HAS_VULKAN
|
||||
static ShaderPair BuildShader(boo::VulkanDataFactory::Context& ctx, const SFluidPlaneShaderInfo& info);
|
||||
static ShaderPair BuildShader(boo::VulkanDataFactory::Context& ctx, const SFluidPlaneDoorShaderInfo& info);
|
||||
BindingPair BuildBinding(boo::VulkanDataFactory::Context& ctx, const ShaderPair& pipeline);
|
||||
#endif
|
||||
|
||||
template <class F>
|
||||
static void _Shutdown();
|
||||
|
||||
void PrepareBinding(u32 maxVertCount);
|
||||
|
||||
|
@ -145,34 +92,20 @@ public:
|
|||
const TLockedToken<CTexture>& patternTex2, const TLockedToken<CTexture>& colorTex,
|
||||
const TLockedToken<CTexture>& bumpMap, const TLockedToken<CTexture>& envMap,
|
||||
const TLockedToken<CTexture>& envBumpMap, const TLockedToken<CTexture>& lightmap,
|
||||
const boo::ObjToken<boo::ITextureS>& rippleMap, bool doubleLightmapBlend, bool additive,
|
||||
hsh::texture2d rippleMap, bool doubleLightmapBlend, bool additive,
|
||||
u32 maxVertCount);
|
||||
CFluidPlaneShader(const TLockedToken<CTexture>& patternTex1, const TLockedToken<CTexture>& patternTex2,
|
||||
const TLockedToken<CTexture>& colorTex, u32 maxVertCount);
|
||||
void prepareDraw(const RenderSetupInfo& info);
|
||||
void prepareDraw(const RenderSetupInfo& info, const zeus::CVector3f& waterCenter, const CRippleManager& rippleManager,
|
||||
const zeus::CColor& colorMul, float rippleNormResolution);
|
||||
void bindRegular() {
|
||||
if (m_lastBind != 0) {
|
||||
CGraphics::SetShaderDataBinding(m_dataBind.m_regular);
|
||||
m_lastBind = 0;
|
||||
}
|
||||
void drawRegular(u32 start, u32 count) {
|
||||
m_dataBind.m_regular.draw(start, count);
|
||||
}
|
||||
bool bindTessellation() {
|
||||
if (m_lastBind != 1) {
|
||||
CGraphics::SetShaderDataBinding(m_dataBind.m_tessellation);
|
||||
m_lastBind = 1;
|
||||
}
|
||||
return true;
|
||||
void drawTessellation(u32 start, u32 count) {
|
||||
m_dataBind.m_tessellation.draw(start, count);
|
||||
}
|
||||
void doneDrawing() { m_lastBind = -1; }
|
||||
void loadVerts(const std::vector<Vertex>& verts, const std::vector<PatchVertex>& pVerts);
|
||||
bool isReady() const {
|
||||
return m_pipelines.m_regular->isReady() &&
|
||||
(!m_pipelines.m_tessellation || m_pipelines.m_tessellation->isReady());
|
||||
}
|
||||
|
||||
static void Shutdown();
|
||||
};
|
||||
|
||||
} // namespace urde
|
||||
|
|
|
@ -12,25 +12,8 @@
|
|||
|
||||
namespace urde {
|
||||
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_1WayPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_2WayPipeline;
|
||||
|
||||
void CFogVolumeFilter::Initialize() {
|
||||
s_1WayPipeline = hecl::conv->convert(Shader_CFogVolumeFilter1Way{});
|
||||
s_2WayPipeline = hecl::conv->convert(Shader_CFogVolumeFilter2Way{});
|
||||
}
|
||||
|
||||
void CFogVolumeFilter::Shutdown() {
|
||||
s_1WayPipeline.reset();
|
||||
s_2WayPipeline.reset();
|
||||
}
|
||||
|
||||
CFogVolumeFilter::CFogVolumeFilter() {
|
||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
||||
struct Vert {
|
||||
zeus::CVector2f m_pos;
|
||||
zeus::CVector2f m_uv;
|
||||
};
|
||||
constexpr std::array<Vert, 4> verts{{
|
||||
{{-1.0, -1.0}, {0.0, 0.0}},
|
||||
{{-1.0, 1.0}, {0.0, 1.0}},
|
||||
|
|
|
@ -1,12 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <boo/BooObject.hpp>
|
||||
|
||||
namespace boo {
|
||||
struct IGraphicsBufferD;
|
||||
struct IGraphicsBufferS;
|
||||
struct IShaderDataBinding;
|
||||
} // namespace boo
|
||||
#include "hsh/hsh.h"
|
||||
|
||||
namespace zeus {
|
||||
class CColor;
|
||||
|
@ -15,14 +9,20 @@ class CColor;
|
|||
namespace urde {
|
||||
|
||||
class CFogVolumeFilter {
|
||||
boo::ObjToken<boo::IGraphicsBufferS> m_vbo;
|
||||
boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
|
||||
boo::ObjToken<boo::IShaderDataBinding> m_dataBind1Way;
|
||||
boo::ObjToken<boo::IShaderDataBinding> m_dataBind2Way;
|
||||
struct Vert {
|
||||
hsh::float2 m_pos;
|
||||
hsh::float2 m_uv;
|
||||
};
|
||||
struct Uniform {
|
||||
hsh::float4 m_color;
|
||||
};
|
||||
|
||||
hsh::owner<hsh::vertex_buffer<Vert>> m_vbo;
|
||||
hsh::dynamic_owner<hsh::uniform_buffer<Uniform>> m_uniBuf;
|
||||
hsh::binding m_dataBind1Way;
|
||||
hsh::binding m_dataBind2Way;
|
||||
|
||||
public:
|
||||
static void Initialize();
|
||||
static void Shutdown();
|
||||
CFogVolumeFilter();
|
||||
void draw2WayPass(const zeus::CColor& color);
|
||||
void draw1WayPass(const zeus::CColor& color);
|
||||
|
|
|
@ -2,64 +2,83 @@
|
|||
|
||||
#include "Runtime/Graphics/CGraphics.hpp"
|
||||
|
||||
#include <hecl/Pipeline.hpp>
|
||||
#include "CFogVolumePlaneShader.cpp.hshhead"
|
||||
|
||||
namespace urde {
|
||||
using namespace hsh::pipeline;
|
||||
|
||||
static std::array<boo::ObjToken<boo::IShaderPipeline>, 4> s_Pipelines;
|
||||
template <size_t I>
|
||||
struct CFogVolumePlanePipelineConfig : pipeline<color_attachment<>> {};
|
||||
|
||||
void CFogVolumePlaneShader::Initialize() {
|
||||
s_Pipelines[0] = hecl::conv->convert(Shader_CFogVolumePlaneShader0{});
|
||||
s_Pipelines[1] = hecl::conv->convert(Shader_CFogVolumePlaneShader1{});
|
||||
s_Pipelines[2] = hecl::conv->convert(Shader_CFogVolumePlaneShader2{});
|
||||
s_Pipelines[3] = hecl::conv->convert(Shader_CFogVolumePlaneShader3{});
|
||||
}
|
||||
using AlphaOnlyAttachment =
|
||||
color_attachment<hsh::Zero, hsh::Zero, hsh::Add, hsh::One, hsh::Zero, hsh::Add, hsh::CC_Alpha>;
|
||||
|
||||
void CFogVolumePlaneShader::Shutdown() {
|
||||
s_Pipelines[0].reset();
|
||||
s_Pipelines[1].reset();
|
||||
s_Pipelines[2].reset();
|
||||
s_Pipelines[3].reset();
|
||||
}
|
||||
template <>
|
||||
struct CFogVolumePlanePipelineConfig<0>
|
||||
: pipeline<AlphaOnlyAttachment, depth_compare<hsh::LEqual>, depth_write<true>, cull_mode<hsh::CullFront>> {};
|
||||
|
||||
template <>
|
||||
struct CFogVolumePlanePipelineConfig<1>
|
||||
: pipeline<AlphaOnlyAttachment, depth_compare<hsh::Always>, depth_write<false>, cull_mode<hsh::CullFront>> {};
|
||||
|
||||
template <>
|
||||
struct CFogVolumePlanePipelineConfig<2>
|
||||
: pipeline<AlphaOnlyAttachment, depth_compare<hsh::LEqual>, depth_write<true>, cull_mode<hsh::CullBack>> {};
|
||||
|
||||
template <>
|
||||
struct CFogVolumePlanePipelineConfig<3>
|
||||
: pipeline<AlphaOnlyAttachment, depth_compare<hsh::Greater>, depth_write<false>, cull_mode<hsh::CullBack>> {};
|
||||
|
||||
template <size_t I>
|
||||
struct CFogVolumePlanePipeline : CFogVolumePlanePipelineConfig<I> {
|
||||
CFogVolumePlanePipeline(hsh::vertex_buffer<CFogVolumePlaneShader::Vert> vbo) {
|
||||
this->position = vbo->pos;
|
||||
this->color_out[0] = hsh::float4(1.f);
|
||||
}
|
||||
};
|
||||
|
||||
template struct CFogVolumePlanePipeline<0>;
|
||||
template struct CFogVolumePlanePipeline<1>;
|
||||
template struct CFogVolumePlanePipeline<2>;
|
||||
template struct CFogVolumePlanePipeline<3>;
|
||||
|
||||
void CFogVolumePlaneShader::CommitResources(size_t capacity) {
|
||||
m_vertCapacity = capacity;
|
||||
CGraphics::CommitResources([this, capacity](boo::IGraphicsDataFactory::Context& ctx) {
|
||||
m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(zeus::CVector4f), capacity);
|
||||
for (size_t i = 0; i < m_dataBinds.size(); ++i) {
|
||||
m_dataBinds[i] = ctx.newShaderDataBinding(s_Pipelines[i], m_vbo.get(), nullptr, nullptr, 0, nullptr, nullptr,
|
||||
nullptr, nullptr, 0, nullptr, nullptr, nullptr);
|
||||
}
|
||||
return true;
|
||||
} BooTrace);
|
||||
m_vbo = hsh::create_dynamic_vertex_buffer<Vert>(capacity);
|
||||
for (size_t i = 0; i < m_dataBinds.size(); ++i) {
|
||||
m_dataBinds[i].hsh_bind(CFogVolumePlanePipeline<i>(m_vbo.get()));
|
||||
}
|
||||
}
|
||||
|
||||
void CFogVolumePlaneShader::addFan(const zeus::CVector3f* verts, int numVerts) {
|
||||
void CFogVolumePlaneShader::addFan(const zeus::CVector3f* verts, size_t numVerts) {
|
||||
zeus::CMatrix4f proj = CGraphics::GetPerspectiveProjectionMatrix(true);
|
||||
zeus::CVector4f vert0 = proj * zeus::CVector4f(CGraphics::g_GXModelView * verts[0]);
|
||||
if (m_verts.size()) {
|
||||
if (!m_verts.empty()) {
|
||||
m_verts.push_back(m_verts.back());
|
||||
m_verts.push_back(vert0);
|
||||
if (m_verts.size() & 1)
|
||||
m_verts.push_back(vert0);
|
||||
m_verts.emplace_back(vert0);
|
||||
if ((m_verts.size() & size_t(1)) != 0) {
|
||||
m_verts.emplace_back(vert0);
|
||||
}
|
||||
}
|
||||
TriFanToStrip<Vert> fanToStrip(m_verts);
|
||||
fanToStrip.EmplaceVert(vert0);
|
||||
for (size_t i = 1; i < numVerts; ++i) {
|
||||
fanToStrip.EmplaceVert(proj * zeus::CVector4f(CGraphics::g_GXModelView * verts[i]));
|
||||
}
|
||||
TriFanToStrip<zeus::CVector4f> fanToStrip(m_verts);
|
||||
fanToStrip.AddVert(vert0);
|
||||
for (int i = 1; i < numVerts; ++i)
|
||||
fanToStrip.AddVert(proj * zeus::CVector4f(CGraphics::g_GXModelView * verts[i]));
|
||||
}
|
||||
|
||||
void CFogVolumePlaneShader::draw(int pass) {
|
||||
if (m_verts.empty())
|
||||
void CFogVolumePlaneShader::draw(size_t pass) {
|
||||
if (m_verts.empty()) {
|
||||
return;
|
||||
}
|
||||
SCOPED_GRAPHICS_DEBUG_GROUP("CFogVolumePlaneShader::draw", zeus::skMagenta);
|
||||
if (pass == 0) {
|
||||
if (m_vertCapacity < m_verts.size())
|
||||
if (m_vertCapacity < m_verts.size()) {
|
||||
CommitResources(m_verts.size());
|
||||
m_vbo->load(m_verts.data(), m_verts.size() * sizeof(zeus::CVector4f));
|
||||
}
|
||||
m_vbo.load(m_verts);
|
||||
}
|
||||
CGraphics::SetShaderDataBinding(m_dataBinds[pass]);
|
||||
CGraphics::DrawArray(0, m_verts.size());
|
||||
m_dataBinds[pass].draw(0, m_verts.size());
|
||||
}
|
||||
|
||||
} // namespace urde
|
||||
|
|
|
@ -4,35 +4,34 @@
|
|||
#include <cstddef>
|
||||
#include <vector>
|
||||
|
||||
#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
||||
|
||||
#include <zeus/CRectangle.hpp>
|
||||
#include <zeus/CVector4f.hpp>
|
||||
|
||||
namespace zeus {
|
||||
class CVector3f;
|
||||
}
|
||||
#include "zeus/CRectangle.hpp"
|
||||
#include "zeus/CVector4f.hpp"
|
||||
|
||||
namespace urde {
|
||||
|
||||
class CFogVolumePlaneShader {
|
||||
boo::ObjToken<boo::IGraphicsBufferD> m_vbo;
|
||||
std::array<boo::ObjToken<boo::IShaderDataBinding>, 4> m_dataBinds;
|
||||
std::vector<zeus::CVector4f> m_verts;
|
||||
template <size_t I>
|
||||
friend struct CFogVolumePlanePipeline;
|
||||
struct Vert {
|
||||
hsh::float4 pos;
|
||||
Vert(hsh::float4 pos) : pos(pos) {}
|
||||
};
|
||||
|
||||
hsh::dynamic_owner<hsh::vertex_buffer<Vert>> m_vbo;
|
||||
std::array<hsh::binding, 4> m_dataBinds;
|
||||
std::vector<Vert> m_verts;
|
||||
size_t m_vertCapacity = 0;
|
||||
|
||||
void CommitResources(size_t capacity);
|
||||
|
||||
public:
|
||||
static void Initialize();
|
||||
static void Shutdown();
|
||||
static const zeus::CRectangle DefaultRect;
|
||||
void reset(int numVerts) {
|
||||
void reset(size_t numVerts) {
|
||||
m_verts.clear();
|
||||
m_verts.reserve(numVerts);
|
||||
}
|
||||
void addFan(const zeus::CVector3f* verts, int numVerts);
|
||||
void draw(int pass);
|
||||
void addFan(const zeus::CVector3f* verts, size_t numVerts);
|
||||
void draw(size_t pass);
|
||||
};
|
||||
|
||||
} // namespace urde
|
||||
|
|
|
@ -1,120 +1,73 @@
|
|||
#include "Runtime/Graphics/Shaders/CLineRendererShaders.hpp"
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "Runtime/Graphics/CLineRenderer.hpp"
|
||||
|
||||
#include <hecl/Pipeline.hpp>
|
||||
#include "CLineRendererShaders.cpp.hshhead"
|
||||
|
||||
namespace urde {
|
||||
using namespace hsh::pipeline;
|
||||
|
||||
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CLineRendererShaders::m_texAlpha;
|
||||
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CLineRendererShaders::m_texAdditive;
|
||||
|
||||
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CLineRendererShaders::m_noTexAlpha;
|
||||
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CLineRendererShaders::m_noTexAdditive;
|
||||
|
||||
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CLineRendererShaders::m_texAlphaZ;
|
||||
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CLineRendererShaders::m_texAdditiveZ;
|
||||
|
||||
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CLineRendererShaders::m_noTexAlphaZ;
|
||||
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CLineRendererShaders::m_noTexAdditiveZ;
|
||||
|
||||
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CLineRendererShaders::m_noTexAlphaZGEqual;
|
||||
|
||||
void CLineRendererShaders::Initialize() {
|
||||
CGraphics::CommitResources([](boo::IGraphicsDataFactory::Context& ctx) {
|
||||
m_texAlpha = {hecl::conv->convert(ctx, Shader_CLineRendererShaderTexAlpha{}),
|
||||
hecl::conv->convert(ctx, Shader_CLineRendererShaderTexAlphaAWrite{})};
|
||||
m_texAdditive = {hecl::conv->convert(ctx, Shader_CLineRendererShaderTexAdditive{}),
|
||||
hecl::conv->convert(ctx, Shader_CLineRendererShaderTexAdditiveAWrite{})};
|
||||
m_noTexAlpha = {hecl::conv->convert(ctx, Shader_CLineRendererShaderNoTexAlpha{}),
|
||||
hecl::conv->convert(ctx, Shader_CLineRendererShaderNoTexAlphaAWrite{})};
|
||||
m_noTexAdditive = {hecl::conv->convert(ctx, Shader_CLineRendererShaderNoTexAdditive{}),
|
||||
hecl::conv->convert(ctx, Shader_CLineRendererShaderNoTexAdditiveAWrite{})};
|
||||
m_texAlphaZ = {hecl::conv->convert(ctx, Shader_CLineRendererShaderTexAlphaZ{}),
|
||||
hecl::conv->convert(ctx, Shader_CLineRendererShaderTexAlphaZAWrite{})};
|
||||
m_texAdditiveZ = {hecl::conv->convert(ctx, Shader_CLineRendererShaderTexAdditiveZ{}),
|
||||
hecl::conv->convert(ctx, Shader_CLineRendererShaderTexAdditiveZAWrite{})};
|
||||
m_noTexAlphaZ = {hecl::conv->convert(ctx, Shader_CLineRendererShaderNoTexAlphaZ{}),
|
||||
hecl::conv->convert(ctx, Shader_CLineRendererShaderNoTexAlphaZAWrite{})};
|
||||
m_noTexAdditiveZ = {hecl::conv->convert(ctx, Shader_CLineRendererShaderNoTexAdditiveZ{}),
|
||||
hecl::conv->convert(ctx, Shader_CLineRendererShaderNoTexAdditiveZAWrite{})};
|
||||
m_noTexAlphaZGEqual = {hecl::conv->convert(ctx, Shader_CLineRendererShaderNoTexAlphaZGEqual{}),
|
||||
hecl::conv->convert(ctx, Shader_CLineRendererShaderNoTexAlphaZGEqualAWrite{})};
|
||||
return true;
|
||||
} BooTrace);
|
||||
}
|
||||
|
||||
void CLineRendererShaders::Shutdown() {
|
||||
for (auto& s : m_texAlpha) s.reset();
|
||||
for (auto& s : m_texAdditive) s.reset();
|
||||
for (auto& s : m_noTexAlpha) s.reset();
|
||||
for (auto& s : m_noTexAdditive) s.reset();
|
||||
for (auto& s : m_texAlphaZ) s.reset();
|
||||
for (auto& s : m_texAdditiveZ) s.reset();
|
||||
for (auto& s : m_noTexAlphaZ) s.reset();
|
||||
for (auto& s : m_noTexAdditiveZ) s.reset();
|
||||
for (auto& s : m_noTexAlphaZGEqual) s.reset();
|
||||
}
|
||||
|
||||
void CLineRendererShaders::BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, CLineRenderer& renderer,
|
||||
const boo::ObjToken<boo::ITexture>& texture, bool additive,
|
||||
bool zTest, bool zGEqual) {
|
||||
std::array<boo::ObjToken<boo::IShaderPipeline>, 2>* pipeline = nullptr;
|
||||
|
||||
if (zGEqual) {
|
||||
pipeline = &m_noTexAlphaZGEqual;
|
||||
} else if (zTest) {
|
||||
if (texture) {
|
||||
if (additive)
|
||||
pipeline = &m_texAdditiveZ;
|
||||
else
|
||||
pipeline = &m_texAlphaZ;
|
||||
} else {
|
||||
if (additive)
|
||||
pipeline = &m_noTexAdditiveZ;
|
||||
else
|
||||
pipeline = &m_noTexAlphaZ;
|
||||
}
|
||||
} else {
|
||||
if (texture) {
|
||||
if (additive)
|
||||
pipeline = &m_texAdditive;
|
||||
else
|
||||
pipeline = &m_texAlpha;
|
||||
} else {
|
||||
if (additive)
|
||||
pipeline = &m_noTexAdditive;
|
||||
else
|
||||
pipeline = &m_noTexAlpha;
|
||||
}
|
||||
template <bool Additive, bool AlphaWrite, hsh::Compare ZComp>
|
||||
struct CLineRendererTexPipeline
|
||||
: pipeline<std::conditional_t<Additive, AdditiveAttachment<AlphaWrite>, BlendAttachment<AlphaWrite>>,
|
||||
depth_compare<ZComp>> {
|
||||
CLineRendererTexPipeline(hsh::vertex_buffer<CLineRenderer::SDrawVertTex> vbo,
|
||||
hsh::uniform_buffer<CLineRenderer::SDrawUniform> uniBuf HSH_VAR_STAGE(fragment),
|
||||
hsh::texture2d tex) {
|
||||
this->position = vbo->pos;
|
||||
hsh::float4 colorIn = vbo->color * uniBuf->moduColor * tex.sample<float>(vbo->uv);
|
||||
FOG_SHADER(uniBuf->fog)
|
||||
FOG_OUT(this->color_out[0], uniBuf->fog, colorIn)
|
||||
}
|
||||
};
|
||||
template struct CLineRendererTexPipeline<false, false, hsh::Always>;
|
||||
template struct CLineRendererTexPipeline<false, false, hsh::LEqual>;
|
||||
template struct CLineRendererTexPipeline<false, false, hsh::Greater>;
|
||||
template struct CLineRendererTexPipeline<false, true, hsh::Always>;
|
||||
template struct CLineRendererTexPipeline<false, true, hsh::LEqual>;
|
||||
template struct CLineRendererTexPipeline<false, true, hsh::Greater>;
|
||||
template struct CLineRendererTexPipeline<true, false, hsh::Always>;
|
||||
template struct CLineRendererTexPipeline<true, false, hsh::LEqual>;
|
||||
template struct CLineRendererTexPipeline<true, false, hsh::Greater>;
|
||||
template struct CLineRendererTexPipeline<true, true, hsh::Always>;
|
||||
template struct CLineRendererTexPipeline<true, true, hsh::LEqual>;
|
||||
template struct CLineRendererTexPipeline<true, true, hsh::Greater>;
|
||||
|
||||
size_t texCount = 0;
|
||||
std::array<boo::ObjToken<boo::ITexture>, 1> textures;
|
||||
template <bool Additive, bool AlphaWrite, hsh::Compare ZComp>
|
||||
struct CLineRendererNoTexPipeline
|
||||
: pipeline<std::conditional_t<Additive, AdditiveAttachment<AlphaWrite>, BlendAttachment<AlphaWrite>>,
|
||||
depth_compare<ZComp>> {
|
||||
CLineRendererNoTexPipeline(hsh::vertex_buffer<CLineRenderer::SDrawVertTex> vbo,
|
||||
hsh::uniform_buffer<CLineRenderer::SDrawUniform> uniBuf HSH_VAR_STAGE(fragment)) {
|
||||
this->position = vbo->pos;
|
||||
hsh::float4 colorIn = vbo->color * uniBuf->moduColor;
|
||||
FOG_SHADER(uniBuf->fog)
|
||||
FOG_OUT(this->color_out[0], uniBuf->fog, colorIn)
|
||||
}
|
||||
};
|
||||
template struct CLineRendererNoTexPipeline<false, false, hsh::Always>;
|
||||
template struct CLineRendererNoTexPipeline<false, false, hsh::LEqual>;
|
||||
template struct CLineRendererNoTexPipeline<false, false, hsh::Greater>;
|
||||
template struct CLineRendererNoTexPipeline<false, true, hsh::Always>;
|
||||
template struct CLineRendererNoTexPipeline<false, true, hsh::LEqual>;
|
||||
template struct CLineRendererNoTexPipeline<false, true, hsh::Greater>;
|
||||
template struct CLineRendererNoTexPipeline<true, false, hsh::Always>;
|
||||
template struct CLineRendererNoTexPipeline<true, false, hsh::LEqual>;
|
||||
template struct CLineRendererNoTexPipeline<true, false, hsh::Greater>;
|
||||
template struct CLineRendererNoTexPipeline<true, true, hsh::Always>;
|
||||
template struct CLineRendererNoTexPipeline<true, true, hsh::LEqual>;
|
||||
template struct CLineRendererNoTexPipeline<true, true, hsh::Greater>;
|
||||
|
||||
std::pair<boo::ObjToken<boo::IGraphicsBufferD>, hecl::VertexBufferPool<CLineRenderer::SDrawVertTex>::IndexTp>
|
||||
vbufInfo;
|
||||
std::pair<boo::ObjToken<boo::IGraphicsBufferD>, hecl::UniformBufferPool<CLineRenderer::SDrawUniform>::IndexTp>
|
||||
ubufInfo = renderer.m_uniformBuf.getBufferInfo();
|
||||
void CLineRendererShaders::BindShader(CLineRenderer& renderer, hsh::texture2d texture, bool additive,
|
||||
hsh::Compare zcomp) {
|
||||
if (texture) {
|
||||
vbufInfo = renderer.m_vertBufTex.getBufferInfo();
|
||||
textures[0] = texture;
|
||||
texCount = 1;
|
||||
renderer.m_shaderBind[0].hsh_tex_bind(CLineRendererTexPipeline<additive, false, zcomp>(
|
||||
renderer.m_vertBuf.get(), renderer.m_uniformBuf.get(), texture));
|
||||
renderer.m_shaderBind[1].hsh_tex_bind_awrite(CLineRendererTexPipeline<additive, true, zcomp>(
|
||||
renderer.m_vertBuf.get(), renderer.m_uniformBuf.get(), texture));
|
||||
} else {
|
||||
vbufInfo = renderer.m_vertBufNoTex.getBufferInfo();
|
||||
}
|
||||
|
||||
const std::array<boo::ObjToken<boo::IGraphicsBuffer>, 1> uniforms{ubufInfo.first.get()};
|
||||
constexpr std::array<boo::PipelineStage, 1> stages{boo::PipelineStage::Fragment};
|
||||
const std::array<size_t, 1> ubufOffs{size_t(ubufInfo.second)};
|
||||
const std::array<size_t, 1> ubufSizes{sizeof(CLineRenderer::SDrawUniform)};
|
||||
|
||||
for (size_t i = 0; i < renderer.m_shaderBind.size(); ++i) {
|
||||
renderer.m_shaderBind[i] = ctx.newShaderDataBinding(
|
||||
(*pipeline)[i], vbufInfo.first.get(), nullptr, nullptr, uniforms.size(), uniforms.data(), stages.data(),
|
||||
ubufOffs.data(), ubufSizes.data(), texCount, textures.data(), nullptr, nullptr, vbufInfo.second);
|
||||
renderer.m_shaderBind[0].hsh_notex_bind(
|
||||
CLineRendererNoTexPipeline<additive, false, zcomp>(renderer.m_vertBuf.get(), renderer.m_uniformBuf.get()));
|
||||
renderer.m_shaderBind[1].hsh_notex_bind_awrite(
|
||||
CLineRendererNoTexPipeline<additive, true, zcomp>(renderer.m_vertBuf.get(), renderer.m_uniformBuf.get()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,32 +2,15 @@
|
|||
|
||||
#include <array>
|
||||
|
||||
#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
||||
#include "hsh/hsh.h"
|
||||
|
||||
namespace urde {
|
||||
class CLineRenderer;
|
||||
|
||||
class CLineRendererShaders {
|
||||
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texAlpha;
|
||||
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texAdditive;
|
||||
|
||||
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_noTexAlpha;
|
||||
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_noTexAdditive;
|
||||
|
||||
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texAlphaZ;
|
||||
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texAdditiveZ;
|
||||
|
||||
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_noTexAlphaZ;
|
||||
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_noTexAdditiveZ;
|
||||
|
||||
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_noTexAlphaZGEqual;
|
||||
|
||||
public:
|
||||
static void Initialize();
|
||||
static void Shutdown();
|
||||
static void BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, CLineRenderer& renderer,
|
||||
const boo::ObjToken<boo::ITexture>& texture, bool additive, bool zTest,
|
||||
bool zGEqual);
|
||||
static void BindShader(CLineRenderer& renderer, hsh::texture2d texture, bool additive,
|
||||
hsh::Compare zcomp);
|
||||
};
|
||||
|
||||
} // namespace urde
|
||||
|
|
|
@ -4,33 +4,19 @@
|
|||
|
||||
#include "Runtime/Graphics/CGraphics.hpp"
|
||||
|
||||
#include <hecl/Pipeline.hpp>
|
||||
|
||||
namespace urde {
|
||||
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
|
||||
|
||||
void CMapSurfaceShader::Initialize() { s_Pipeline = hecl::conv->convert(Shader_CMapSurfaceShader{}); }
|
||||
|
||||
void CMapSurfaceShader::Shutdown() { s_Pipeline.reset(); }
|
||||
|
||||
CMapSurfaceShader::CMapSurfaceShader(boo::IGraphicsDataFactory::Context& ctx,
|
||||
const boo::ObjToken<boo::IGraphicsBufferS>& vbo,
|
||||
const boo::ObjToken<boo::IGraphicsBufferS>& ibo)
|
||||
: m_vbo(vbo), m_ibo(ibo) {
|
||||
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
|
||||
const std::array<boo::ObjToken<boo::IGraphicsBuffer>, 1> bufs{m_uniBuf.get()};
|
||||
constexpr std::array<boo::PipelineStage, 1> stages{boo::PipelineStage::Vertex};
|
||||
m_dataBind = ctx.newShaderDataBinding(s_Pipeline, m_vbo.get(), nullptr, m_ibo.get(), bufs.size(), bufs.data(),
|
||||
stages.data(), nullptr, nullptr, 0, nullptr, nullptr, nullptr);
|
||||
CMapSurfaceShader::CMapSurfaceShader(hsh::vertex_buffer<Vert> vbo,
|
||||
hsh::index_buffer<uint32_t> ibo) {
|
||||
m_uniBuf = hsh::create_dynamic_uniform_buffer<Uniform>();
|
||||
m_dataBind.hsh_bind(m_uniBuf.get(), vbo, ibo);
|
||||
}
|
||||
|
||||
void CMapSurfaceShader::draw(const zeus::CColor& color, u32 start, u32 count) {
|
||||
SCOPED_GRAPHICS_DEBUG_GROUP("CMapSurfaceShader::draw", zeus::skMagenta);
|
||||
Uniform uniform = {CGraphics::GetPerspectiveProjectionMatrix(true) * CGraphics::g_GXModelView.toMatrix4f(), color};
|
||||
m_uniBuf->load(&uniform, sizeof(Uniform));
|
||||
CGraphics::SetShaderDataBinding(m_dataBind);
|
||||
CGraphics::DrawArrayIndexed(start, count);
|
||||
m_uniBuf.load(uniform);
|
||||
m_dataBind.draw_indexed(start, count);
|
||||
}
|
||||
|
||||
} // namespace urde
|
||||
|
|
|
@ -2,29 +2,30 @@
|
|||
|
||||
#include "Runtime/GCNTypes.hpp"
|
||||
|
||||
#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
||||
|
||||
#include <zeus/CColor.hpp>
|
||||
#include <zeus/CMatrix4f.hpp>
|
||||
#include "zeus/CColor.hpp"
|
||||
#include "zeus/CMatrix4f.hpp"
|
||||
|
||||
namespace urde {
|
||||
|
||||
class CMapSurfaceShader {
|
||||
public:
|
||||
struct Uniform {
|
||||
zeus::CMatrix4f mtx;
|
||||
zeus::CColor color;
|
||||
hsh::float4x4 mtx;
|
||||
hsh::float4 color;
|
||||
};
|
||||
struct Vert {
|
||||
hsh::float3 pos;
|
||||
Vert() = default;
|
||||
Vert(float x, float y, float z) : pos(x, y, z) {}
|
||||
};
|
||||
|
||||
boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
|
||||
boo::ObjToken<boo::IGraphicsBufferS> m_vbo;
|
||||
boo::ObjToken<boo::IGraphicsBufferS> m_ibo;
|
||||
boo::ObjToken<boo::IShaderDataBinding> m_dataBind;
|
||||
private:
|
||||
hsh::dynamic_owner<hsh::uniform_buffer<Uniform>> m_uniBuf;
|
||||
hsh::binding m_dataBind;
|
||||
|
||||
public:
|
||||
static void Initialize();
|
||||
static void Shutdown();
|
||||
CMapSurfaceShader(boo::IGraphicsDataFactory::Context& ctx, const boo::ObjToken<boo::IGraphicsBufferS>& vbo,
|
||||
const boo::ObjToken<boo::IGraphicsBufferS>& ibo);
|
||||
CMapSurfaceShader(hsh::vertex_buffer<Vert> vbo,
|
||||
hsh::index_buffer<uint32_t> ibo);
|
||||
void draw(const zeus::CColor& color, u32 start, u32 count);
|
||||
};
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -20,6 +20,9 @@ class ShaderTag;
|
|||
|
||||
namespace urde {
|
||||
class CLight;
|
||||
class CModelFlags;
|
||||
class CBooSurface;
|
||||
class CBooModel;
|
||||
|
||||
enum class EExtendedShader : uint8_t {
|
||||
Flat,
|
||||
|
@ -51,59 +54,78 @@ enum class EExtendedShader : uint8_t {
|
|||
MAX
|
||||
};
|
||||
|
||||
enum class EShaderType : uint8_t {
|
||||
DiffuseOnly,
|
||||
Normal,
|
||||
Dynamic,
|
||||
DynamicAlpha,
|
||||
DynamicCharacter
|
||||
};
|
||||
|
||||
enum class EPostType : uint8_t {
|
||||
Normal,
|
||||
ThermalHot,
|
||||
ThermalCold,
|
||||
Solid,
|
||||
MBShadow,
|
||||
Disintegrate
|
||||
};
|
||||
|
||||
class CModelShaders {
|
||||
friend class CModel;
|
||||
hsh::binding m_dataBind;
|
||||
|
||||
public:
|
||||
struct Light {
|
||||
zeus::CVector3f pos;
|
||||
zeus::CVector3f dir;
|
||||
zeus::CColor color = zeus::skClear;
|
||||
std::array<float, 4> linAtt{1.f, 0.f, 0.f};
|
||||
std::array<float, 4> angAtt{1.f, 0.f, 0.f};
|
||||
template <uint32_t NCol, uint32_t NUv, uint32_t NWeight>
|
||||
struct VertData {
|
||||
hsh::float3 posIn;
|
||||
hsh::float3 normIn;
|
||||
std::array<hsh::float4, NCol> colIn;
|
||||
std::array<hsh::float2, NUv> uvIn;
|
||||
std::array<hsh::float4, NWeight> weightIn;
|
||||
};
|
||||
|
||||
struct LightingUniform {
|
||||
template <uint32_t NSkinSlots>
|
||||
struct VertUniform {
|
||||
std::array<hsh::float4x4, NSkinSlots> objs;
|
||||
std::array<hsh::float4x4, NSkinSlots> objsInv;
|
||||
hsh::float4x4 mv;
|
||||
hsh::float4x4 mvInv;
|
||||
hsh::float4x4 proj;
|
||||
};
|
||||
|
||||
struct TCGMatrix {
|
||||
hsh::float4x4 mtx;
|
||||
hsh::float4x4 postMtx;
|
||||
};
|
||||
|
||||
struct ReflectMtx {
|
||||
hsh::float4x4 indMtx;
|
||||
hsh::float4x4 reflectMtx;
|
||||
float reflectAlpha;
|
||||
};
|
||||
|
||||
struct Light {
|
||||
alignas(16) hsh::float3 pos;
|
||||
alignas(16) hsh::float3 dir;
|
||||
alignas(16) hsh::float4 color;
|
||||
alignas(16) hsh::float3 linAtt;
|
||||
alignas(16) hsh::float3 angAtt;
|
||||
};
|
||||
|
||||
struct FragmentUniform {
|
||||
std::array<Light, URDE_MAX_LIGHTS> lights;
|
||||
zeus::CColor ambient;
|
||||
std::array<zeus::CColor, 3> colorRegs;
|
||||
zeus::CColor mulColor;
|
||||
zeus::CColor addColor;
|
||||
hsh::float4 ambient;
|
||||
hsh::float4 lightmapMul;
|
||||
hsh::float4 flagsColor;
|
||||
CGraphics::CFogState fog;
|
||||
|
||||
void ActivateLights(const std::vector<CLight>& lts);
|
||||
};
|
||||
|
||||
struct ThermalUniform {
|
||||
zeus::CColor mulColor;
|
||||
zeus::CColor addColor;
|
||||
};
|
||||
|
||||
struct SolidUniform {
|
||||
zeus::CColor solidColor;
|
||||
};
|
||||
|
||||
struct MBShadowUniform {
|
||||
zeus::CVector4f shadowUp;
|
||||
float shadowId;
|
||||
};
|
||||
|
||||
struct OneTextureUniform {
|
||||
zeus::CColor addColor;
|
||||
CGraphics::CFogState fog;
|
||||
};
|
||||
|
||||
static void Initialize();
|
||||
static void Shutdown();
|
||||
|
||||
using ShaderPipelinesData = std::array<boo::ObjToken<boo::IShaderPipeline>, size_t(EExtendedShader::MAX)>;
|
||||
using ShaderPipelines = std::shared_ptr<ShaderPipelinesData>;
|
||||
hsh::binding& SetCurrent(const CModelFlags& modelFlags, const CBooSurface& surface, const CBooModel& model);
|
||||
|
||||
using Material = DataSpec::DNAMP1::HMDLMaterialSet::Material;
|
||||
static ShaderPipelines BuildExtendedShader(const hecl::Backend::ShaderTag& tag, const Material& material);
|
||||
|
||||
private:
|
||||
static std::unordered_map<uint64_t, ShaderPipelines> g_ShaderPipelines;
|
||||
};
|
||||
|
||||
} // namespace urde
|
||||
|
|
|
@ -5,52 +5,8 @@
|
|||
#include "Runtime/Particle/CParticleSwoosh.hpp"
|
||||
#include "Runtime/Particle/CSwooshDescription.hpp"
|
||||
|
||||
#include <hecl/Pipeline.hpp>
|
||||
|
||||
namespace urde {
|
||||
|
||||
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CParticleSwooshShaders::m_texZWrite;
|
||||
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CParticleSwooshShaders::m_texNoZWrite;
|
||||
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CParticleSwooshShaders::m_texAdditiveZWrite;
|
||||
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CParticleSwooshShaders::m_texAdditiveNoZWrite;
|
||||
|
||||
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CParticleSwooshShaders::m_noTexZWrite;
|
||||
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CParticleSwooshShaders::m_noTexNoZWrite;
|
||||
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CParticleSwooshShaders::m_noTexAdditiveZWrite;
|
||||
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CParticleSwooshShaders::m_noTexAdditiveNoZWrite;
|
||||
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
|
||||
|
||||
void CParticleSwooshShaders::Initialize() {
|
||||
m_texZWrite = {hecl::conv->convert(Shader_CParticleSwooshShaderTexZWrite{}),
|
||||
hecl::conv->convert(Shader_CParticleSwooshShaderTexZWriteAWrite{})};
|
||||
m_texNoZWrite = {hecl::conv->convert(Shader_CParticleSwooshShaderTexNoZWrite{}),
|
||||
hecl::conv->convert(Shader_CParticleSwooshShaderTexNoZWriteAWrite{})};
|
||||
m_texAdditiveZWrite = {hecl::conv->convert(Shader_CParticleSwooshShaderTexAdditiveZWrite{}),
|
||||
hecl::conv->convert(Shader_CParticleSwooshShaderTexAdditiveZWriteAWrite{})};
|
||||
m_texAdditiveNoZWrite = {hecl::conv->convert(Shader_CParticleSwooshShaderTexAdditiveNoZWrite{}),
|
||||
hecl::conv->convert(Shader_CParticleSwooshShaderTexAdditiveNoZWriteAWrite{})};
|
||||
m_noTexZWrite = {hecl::conv->convert(Shader_CParticleSwooshShaderNoTexZWrite{}),
|
||||
hecl::conv->convert(Shader_CParticleSwooshShaderNoTexZWriteAWrite{})};
|
||||
m_noTexNoZWrite = {hecl::conv->convert(Shader_CParticleSwooshShaderNoTexNoZWrite{}),
|
||||
hecl::conv->convert(Shader_CParticleSwooshShaderNoTexNoZWriteAWrite{})};
|
||||
m_noTexAdditiveZWrite = {hecl::conv->convert(Shader_CParticleSwooshShaderNoTexAdditiveZWrite{}),
|
||||
hecl::conv->convert(Shader_CParticleSwooshShaderNoTexAdditiveZWriteAWrite{})};
|
||||
m_noTexAdditiveNoZWrite = {hecl::conv->convert(Shader_CParticleSwooshShaderNoTexAdditiveNoZWrite{}),
|
||||
hecl::conv->convert(Shader_CParticleSwooshShaderNoTexAdditiveNoZWriteAWrite{})};
|
||||
}
|
||||
|
||||
void CParticleSwooshShaders::Shutdown() {
|
||||
for (auto& s : m_texZWrite) s.reset();
|
||||
for (auto& s : m_texNoZWrite) s.reset();
|
||||
for (auto& s : m_texAdditiveZWrite) s.reset();
|
||||
for (auto& s : m_texAdditiveNoZWrite) s.reset();
|
||||
for (auto& s : m_noTexZWrite) s.reset();
|
||||
for (auto& s : m_noTexNoZWrite) s.reset();
|
||||
for (auto& s : m_noTexAdditiveZWrite) s.reset();
|
||||
for (auto& s : m_noTexAdditiveNoZWrite) s.reset();
|
||||
}
|
||||
|
||||
CParticleSwooshShaders::EShaderClass CParticleSwooshShaders::GetShaderClass(CParticleSwoosh& gen) {
|
||||
CSwooshDescription* desc = gen.GetDesc();
|
||||
|
||||
|
@ -60,7 +16,7 @@ CParticleSwooshShaders::EShaderClass CParticleSwooshShaders::GetShaderClass(CPar
|
|||
return EShaderClass::NoTex;
|
||||
}
|
||||
|
||||
void CParticleSwooshShaders::BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, CParticleSwoosh& gen) {
|
||||
void CParticleSwooshShaders::BuildShaderDataBinding(CParticleSwoosh& gen) {
|
||||
CSwooshDescription* desc = gen.GetDesc();
|
||||
std::array<boo::ObjToken<boo::IShaderPipeline>, 2>* pipeline = nullptr;
|
||||
|
||||
|
|
|
@ -2,11 +2,7 @@
|
|||
|
||||
#include <array>
|
||||
|
||||
#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
||||
|
||||
#include <zeus/CColor.hpp>
|
||||
#include <zeus/CVector2f.hpp>
|
||||
#include <zeus/CVector3f.hpp>
|
||||
#include "hsh/hsh.h"
|
||||
|
||||
namespace urde {
|
||||
class CParticleSwoosh;
|
||||
|
@ -16,27 +12,17 @@ public:
|
|||
enum class EShaderClass { Tex, NoTex };
|
||||
|
||||
struct Vert {
|
||||
zeus::CVector3f m_pos;
|
||||
zeus::CVector2f m_uv;
|
||||
zeus::CColor m_color;
|
||||
hsh::float3 m_pos;
|
||||
hsh::float2 m_uv;
|
||||
hsh::float4 m_color;
|
||||
};
|
||||
|
||||
private:
|
||||
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texZWrite;
|
||||
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texNoZWrite;
|
||||
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texAdditiveZWrite;
|
||||
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texAdditiveNoZWrite;
|
||||
struct Uniform {
|
||||
hsh::float4x4 m_xf;
|
||||
};
|
||||
|
||||
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_noTexZWrite;
|
||||
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_noTexNoZWrite;
|
||||
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_noTexAdditiveZWrite;
|
||||
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_noTexAdditiveNoZWrite;
|
||||
|
||||
public:
|
||||
static void Initialize();
|
||||
static void Shutdown();
|
||||
static EShaderClass GetShaderClass(CParticleSwoosh& gen);
|
||||
static void BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, CParticleSwoosh& gen);
|
||||
static void BuildShaderDataBinding(CParticleSwoosh& gen);
|
||||
};
|
||||
|
||||
} // namespace urde
|
||||
|
|
|
@ -5,31 +5,13 @@
|
|||
#include "Runtime/Graphics/CGraphics.hpp"
|
||||
#include "Runtime/Graphics/CTexture.hpp"
|
||||
|
||||
#include <hecl/Pipeline.hpp>
|
||||
|
||||
#include <zeus/CColor.hpp>
|
||||
#include <zeus/CVector2f.hpp>
|
||||
#include <zeus/CVector3f.hpp>
|
||||
#include <zeus/CVector4f.hpp>
|
||||
#include "zeus/CColor.hpp"
|
||||
#include "zeus/CVector2f.hpp"
|
||||
#include "zeus/CVector3f.hpp"
|
||||
#include "zeus/CVector4f.hpp"
|
||||
|
||||
namespace urde {
|
||||
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_IndPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_BlurPipeline;
|
||||
|
||||
void CPhazonSuitFilter::Initialize() {
|
||||
s_IndPipeline = hecl::conv->convert(Shader_CPhazonSuitFilterInd{});
|
||||
s_Pipeline = hecl::conv->convert(Shader_CPhazonSuitFilterNoInd{});
|
||||
s_BlurPipeline = hecl::conv->convert(Shader_CPhazonSuitFilterBlur{});
|
||||
}
|
||||
|
||||
void CPhazonSuitFilter::Shutdown() {
|
||||
s_IndPipeline.reset();
|
||||
s_Pipeline.reset();
|
||||
s_BlurPipeline.reset();
|
||||
}
|
||||
|
||||
void CPhazonSuitFilter::drawBlurPasses(float radius, const CTexture* indTex) {
|
||||
SCOPED_GRAPHICS_DEBUG_GROUP("CPhazonSuitFilter::drawBlurPasses", zeus::skMagenta);
|
||||
if (!m_dataBind || indTex != m_indTex) {
|
||||
|
@ -39,10 +21,6 @@ void CPhazonSuitFilter::drawBlurPasses(float radius, const CTexture* indTex) {
|
|||
m_uniBufBlurY = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(zeus::CVector4f), 1);
|
||||
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(zeus::CVector4f) * 2, 1);
|
||||
|
||||
struct BlurVert {
|
||||
zeus::CVector3f pos;
|
||||
zeus::CVector2f uv;
|
||||
};
|
||||
const std::array<BlurVert, 4> blurVerts{{
|
||||
{{-1.f, 1.f, 0.f}, {0.f, 1.f}},
|
||||
{{-1.f, -1.f, 0.f}, {0.f, 0.f}},
|
||||
|
@ -51,12 +29,6 @@ void CPhazonSuitFilter::drawBlurPasses(float radius, const CTexture* indTex) {
|
|||
}};
|
||||
m_blurVbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, blurVerts.data(), sizeof(BlurVert), blurVerts.size());
|
||||
|
||||
struct Vert {
|
||||
zeus::CVector3f pos;
|
||||
zeus::CVector2f screenUv;
|
||||
zeus::CVector2f indUv;
|
||||
zeus::CVector2f maskUv;
|
||||
};
|
||||
const std::array<Vert, 4> verts{{
|
||||
{{-1.f, 1.f, 0.f}, {0.01f, 0.99f}, {0.f, 4.f}, {0.f, 1.f}},
|
||||
{{-1.f, -1.f, 0.f}, {0.01f, 0.01f}, {0.f, 0.f}, {0.f, 0.f}},
|
||||
|
@ -139,10 +111,7 @@ void CPhazonSuitFilter::drawBlurPasses(float radius, const CTexture* indTex) {
|
|||
|
||||
void CPhazonSuitFilter::draw(const zeus::CColor& color, float indScale, float indOffX, float indOffY) {
|
||||
SCOPED_GRAPHICS_DEBUG_GROUP("CPhazonSuitFilter::draw", zeus::skMagenta);
|
||||
struct Uniform {
|
||||
zeus::CColor color;
|
||||
zeus::CVector4f indScaleOff;
|
||||
} uniform = {color, zeus::CVector4f(indScale, indScale, indOffX, indOffY)};
|
||||
Uniform uniform = {color, zeus::CVector4f(indScale, indScale, indOffX, indOffY)};
|
||||
|
||||
m_uniBuf->load(&uniform, sizeof(Uniform));
|
||||
CGraphics::SetShaderDataBinding(m_dataBind);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
||||
#include "hsh/hsh.h"
|
||||
|
||||
namespace zeus {
|
||||
class CColor;
|
||||
|
@ -10,19 +10,32 @@ namespace urde {
|
|||
class CTexture;
|
||||
|
||||
class CPhazonSuitFilter {
|
||||
boo::ObjToken<boo::IGraphicsBufferD> m_uniBufBlurX;
|
||||
boo::ObjToken<boo::IGraphicsBufferD> m_uniBufBlurY;
|
||||
boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
|
||||
boo::ObjToken<boo::IGraphicsBufferS> m_blurVbo;
|
||||
boo::ObjToken<boo::IGraphicsBufferS> m_vbo;
|
||||
struct BlurUniform {
|
||||
hsh::float4 blur;
|
||||
};
|
||||
struct Uniform {
|
||||
hsh::float4 color;
|
||||
hsh::float4 indScaleOff;
|
||||
};
|
||||
struct BlurVert {
|
||||
hsh::float3 pos;
|
||||
hsh::float2 uv;
|
||||
};
|
||||
struct Vert {
|
||||
hsh::float3 pos;
|
||||
hsh::float2 screenUv;
|
||||
hsh::float2 indUv;
|
||||
hsh::float2 maskUv;
|
||||
};
|
||||
|
||||
hsh::dynamic_owner<hsh::uniform_buffer<BlurUniform>> m_uniBufBlurX, m_uniBufBlurY;
|
||||
hsh::dynamic_owner<hsh::uniform_buffer<Uniform>> m_uniBuf;
|
||||
hsh::owner<hsh::vertex_buffer<BlurVert>> m_blurVbo;
|
||||
hsh::owner<hsh::vertex_buffer<Vert>> m_vbo;
|
||||
const CTexture* m_indTex = nullptr;
|
||||
boo::ObjToken<boo::IShaderDataBinding> m_dataBindBlurX;
|
||||
boo::ObjToken<boo::IShaderDataBinding> m_dataBindBlurY;
|
||||
boo::ObjToken<boo::IShaderDataBinding> m_dataBind;
|
||||
hsh::binding m_dataBindBlurX, m_dataBindBlurY, m_dataBind;
|
||||
|
||||
public:
|
||||
static void Initialize();
|
||||
static void Shutdown();
|
||||
void drawBlurPasses(float radius, const CTexture* indTex);
|
||||
void draw(const zeus::CColor& color, float indScale, float indOffX, float indOffY);
|
||||
};
|
||||
|
|
|
@ -5,16 +5,8 @@
|
|||
#include "Runtime/Graphics/CGraphics.hpp"
|
||||
#include "Runtime/Graphics/CTexture.hpp"
|
||||
|
||||
#include <hecl/Pipeline.hpp>
|
||||
|
||||
namespace urde {
|
||||
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
|
||||
|
||||
void CRadarPaintShader::Initialize() { s_Pipeline = hecl::conv->convert(Shader_CRadarPaintShader{}); }
|
||||
|
||||
void CRadarPaintShader::Shutdown() { s_Pipeline.reset(); }
|
||||
|
||||
void CRadarPaintShader::draw(const std::vector<Instance>& instances, const CTexture* tex) {
|
||||
if (!instances.size())
|
||||
return;
|
||||
|
|
|
@ -3,11 +3,9 @@
|
|||
#include <array>
|
||||
#include <vector>
|
||||
|
||||
#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
||||
|
||||
#include <zeus/CColor.hpp>
|
||||
#include <zeus/CVector2f.hpp>
|
||||
#include <zeus/CVector3f.hpp>
|
||||
#include "zeus/CColor.hpp"
|
||||
#include "zeus/CVector2f.hpp"
|
||||
#include "zeus/CVector3f.hpp"
|
||||
|
||||
namespace urde {
|
||||
class CTexture;
|
||||
|
@ -19,17 +17,18 @@ public:
|
|||
std::array<zeus::CVector2f, 4> uv;
|
||||
zeus::CColor color;
|
||||
};
|
||||
struct Uniform {
|
||||
hsh::float4x4 xf;
|
||||
};
|
||||
|
||||
private:
|
||||
boo::ObjToken<boo::IGraphicsBufferD> m_vbo;
|
||||
boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
|
||||
boo::ObjToken<boo::IShaderDataBinding> m_dataBind;
|
||||
hsh::dynamic_owner<hsh::vertex_buffer<Instance>> m_vbo;
|
||||
hsh::dynamic_owner<hsh::uniform_buffer<Uniform>> m_uniBuf;
|
||||
hsh::binding m_dataBind;
|
||||
const CTexture* m_tex = nullptr;
|
||||
size_t m_maxInsts = 0;
|
||||
|
||||
public:
|
||||
static void Initialize();
|
||||
static void Shutdown();
|
||||
void draw(const std::vector<Instance>& instances, const CTexture* tex);
|
||||
};
|
||||
|
||||
|
|
|
@ -6,29 +6,8 @@
|
|||
#include "Runtime/Camera/CCameraFilter.hpp"
|
||||
#include "Runtime/Graphics/CBooRenderer.hpp"
|
||||
|
||||
#include <hecl/Pipeline.hpp>
|
||||
|
||||
namespace urde {
|
||||
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_AlphaPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_AddPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_MultPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_CookieCutterPipeline;
|
||||
|
||||
void CRandomStaticFilter::Initialize() {
|
||||
s_AlphaPipeline = hecl::conv->convert(Shader_CRandomStaticFilterAlpha{});
|
||||
s_AddPipeline = hecl::conv->convert(Shader_CRandomStaticFilterAdd{});
|
||||
s_MultPipeline = hecl::conv->convert(Shader_CRandomStaticFilterMult{});
|
||||
s_CookieCutterPipeline = hecl::conv->convert(Shader_CRandomStaticFilterCookieCutter{});
|
||||
}
|
||||
|
||||
void CRandomStaticFilter::Shutdown() {
|
||||
s_AlphaPipeline.reset();
|
||||
s_AddPipeline.reset();
|
||||
s_MultPipeline.reset();
|
||||
s_CookieCutterPipeline.reset();
|
||||
}
|
||||
|
||||
static boo::ObjToken<boo::IShaderPipeline> SelectPipeline(EFilterType type) {
|
||||
switch (type) {
|
||||
case EFilterType::Blend:
|
||||
|
@ -44,10 +23,6 @@ static boo::ObjToken<boo::IShaderPipeline> SelectPipeline(EFilterType type) {
|
|||
|
||||
CRandomStaticFilter::CRandomStaticFilter(EFilterType type, bool cookieCutter) : m_cookieCutter(cookieCutter) {
|
||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
||||
struct Vert {
|
||||
zeus::CVector2f m_pos;
|
||||
zeus::CVector2f m_uv;
|
||||
};
|
||||
const std::array<Vert, 4> verts{{
|
||||
{{-1.f, -1.f}, {0.f, 0.f}},
|
||||
{{-1.f, 1.f}, {0.f, 448.f}},
|
||||
|
|
|
@ -2,9 +2,6 @@
|
|||
|
||||
#include "Runtime/CToken.hpp"
|
||||
|
||||
#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
||||
#include <zeus/CColor.hpp>
|
||||
|
||||
namespace urde {
|
||||
class CTexture;
|
||||
|
||||
|
@ -13,19 +10,21 @@ enum class EFilterType;
|
|||
|
||||
class CRandomStaticFilter {
|
||||
struct Uniform {
|
||||
zeus::CColor color;
|
||||
hsh::float4 color;
|
||||
float randOff;
|
||||
float discardThres;
|
||||
};
|
||||
boo::ObjToken<boo::IGraphicsBufferS> m_vbo;
|
||||
boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
|
||||
boo::ObjToken<boo::IShaderDataBinding> m_dataBind;
|
||||
struct Vert {
|
||||
hsh::float2 m_pos;
|
||||
hsh::float2 m_uv;
|
||||
};
|
||||
hsh::owner<hsh::vertex_buffer<Vert>> m_vbo;
|
||||
hsh::dynamic_owner<hsh::uniform_buffer<Uniform>> m_uniBuf;
|
||||
hsh::binding m_dataBind;
|
||||
Uniform m_uniform;
|
||||
bool m_cookieCutter;
|
||||
|
||||
public:
|
||||
static void Initialize();
|
||||
static void Shutdown();
|
||||
explicit CRandomStaticFilter(EFilterType type, bool cookieCutter = false);
|
||||
explicit CRandomStaticFilter(EFilterType type, const TLockedToken<CTexture>&) : CRandomStaticFilter(type) {}
|
||||
void draw(const zeus::CColor& color, float t);
|
||||
|
|
|
@ -7,26 +7,8 @@
|
|||
#include "Runtime/Graphics/CBooRenderer.hpp"
|
||||
#include "Runtime/Graphics/CGraphics.hpp"
|
||||
|
||||
#include <hecl/Pipeline.hpp>
|
||||
|
||||
namespace urde {
|
||||
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_AlphaPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_AddPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_MultPipeline;
|
||||
|
||||
void CScanLinesFilter::Initialize() {
|
||||
s_AlphaPipeline = hecl::conv->convert(Shader_CScanLinesFilterAlpha{});
|
||||
s_AddPipeline = hecl::conv->convert(Shader_CScanLinesFilterAdd{});
|
||||
s_MultPipeline = hecl::conv->convert(Shader_CScanLinesFilterMult{});
|
||||
}
|
||||
|
||||
void CScanLinesFilter::Shutdown() {
|
||||
s_AlphaPipeline.reset();
|
||||
s_AddPipeline.reset();
|
||||
s_MultPipeline.reset();
|
||||
}
|
||||
|
||||
static boo::ObjToken<boo::IShaderPipeline> SelectPipeline(EFilterType type) {
|
||||
switch (type) {
|
||||
case EFilterType::Blend:
|
||||
|
|
|
@ -2,8 +2,7 @@
|
|||
|
||||
#include "Runtime/CToken.hpp"
|
||||
|
||||
#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
||||
#include <zeus/CColor.hpp>
|
||||
#include "zeus/CColor.hpp"
|
||||
|
||||
namespace urde {
|
||||
class CTexture;
|
||||
|
@ -15,14 +14,12 @@ class CScanLinesFilter {
|
|||
struct Uniform {
|
||||
zeus::CColor color;
|
||||
};
|
||||
boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
|
||||
boo::ObjToken<boo::IShaderDataBinding> m_dataBind;
|
||||
hsh::dynamic_owner<hsh::uniform_buffer<Uniform>> m_uniBuf;
|
||||
hsh::binding m_dataBind;
|
||||
Uniform m_uniform;
|
||||
bool m_even;
|
||||
|
||||
public:
|
||||
static void Initialize();
|
||||
static void Shutdown();
|
||||
explicit CScanLinesFilter(EFilterType type, bool even);
|
||||
void draw(const zeus::CColor& color);
|
||||
void DrawFilter(EFilterShape, const zeus::CColor& color, float) { draw(color); }
|
||||
|
|
|
@ -3,18 +3,10 @@
|
|||
#include "Runtime/Graphics/CBooRenderer.hpp"
|
||||
#include "Runtime/Graphics/CGraphics.hpp"
|
||||
|
||||
#include <hecl/Pipeline.hpp>
|
||||
|
||||
#define WARP_RAMP_RES 32
|
||||
|
||||
namespace urde {
|
||||
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
|
||||
|
||||
void CSpaceWarpFilter::Initialize() { s_Pipeline = hecl::conv->convert(Shader_CSpaceWarpFilter{}); }
|
||||
|
||||
void CSpaceWarpFilter::Shutdown() { s_Pipeline.reset(); }
|
||||
|
||||
void CSpaceWarpFilter::GenerateWarpRampTex(boo::IGraphicsDataFactory::Context& ctx) {
|
||||
std::array<std::array<std::array<u8, 4>, WARP_RAMP_RES + 1>, WARP_RAMP_RES + 1> data{};
|
||||
const float halfRes = WARP_RAMP_RES / 2.f;
|
||||
|
@ -41,10 +33,6 @@ CSpaceWarpFilter::CSpaceWarpFilter() {
|
|||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
||||
GenerateWarpRampTex(ctx);
|
||||
|
||||
struct Vert {
|
||||
zeus::CVector2f m_pos;
|
||||
zeus::CVector2f m_uv;
|
||||
};
|
||||
const std::array<Vert, 4> verts{{
|
||||
{{-1.f, -1.f}, {0.f, 0.f}},
|
||||
{{-1.f, 1.f}, {0.f, 1.f}},
|
||||
|
|
|
@ -4,32 +4,31 @@
|
|||
|
||||
#include "Runtime/GCNTypes.hpp"
|
||||
|
||||
#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
||||
|
||||
#include <zeus/CMatrix4f.hpp>
|
||||
#include <zeus/CVector3f.hpp>
|
||||
#include "zeus/CVector3f.hpp"
|
||||
|
||||
namespace urde {
|
||||
|
||||
class CSpaceWarpFilter {
|
||||
struct Uniform {
|
||||
zeus::CMatrix4f m_matrix;
|
||||
zeus::CMatrix4f m_indXf;
|
||||
zeus::CVector3f m_strength;
|
||||
hsh::float4x4 m_matrix;
|
||||
hsh::float4x4 m_indXf;
|
||||
hsh::float3 m_strength;
|
||||
};
|
||||
struct Vert {
|
||||
hsh::float2 m_pos;
|
||||
hsh::float2 m_uv;
|
||||
};
|
||||
std::array<std::array<std::array<u8, 4>, 8>, 4> m_shiftTexture{};
|
||||
boo::ObjToken<boo::ITexture> m_warpTex;
|
||||
boo::ObjToken<boo::IGraphicsBufferS> m_vbo;
|
||||
boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
|
||||
boo::ObjToken<boo::IShaderDataBinding> m_dataBind;
|
||||
hsh::owner<hsh::texture2d> m_warpTex;
|
||||
hsh::owner<hsh::vertex_buffer<Vert>> m_vbo;
|
||||
hsh::dynamic_owner<hsh::uniform_buffer<Uniform>> m_uniBuf;
|
||||
hsh::binding m_dataBind;
|
||||
Uniform m_uniform;
|
||||
float m_strength = 1.f;
|
||||
|
||||
void GenerateWarpRampTex(boo::IGraphicsDataFactory::Context& ctx);
|
||||
void GenerateWarpRampTex();
|
||||
|
||||
public:
|
||||
static void Initialize();
|
||||
static void Shutdown();
|
||||
CSpaceWarpFilter();
|
||||
void setStrength(float strength) { m_strength = strength; }
|
||||
void draw(const zeus::CVector3f& pt);
|
||||
|
|
|
@ -2,44 +2,8 @@
|
|||
|
||||
#include "Runtime/GuiSys/CRasterFont.hpp"
|
||||
|
||||
#include <hecl/Pipeline.hpp>
|
||||
|
||||
namespace urde {
|
||||
|
||||
boo::ObjToken<boo::IShaderPipeline> CTextSupportShader::s_TextAlphaPipeline;
|
||||
boo::ObjToken<boo::IShaderPipeline> CTextSupportShader::s_TextAddPipeline;
|
||||
boo::ObjToken<boo::IShaderPipeline> CTextSupportShader::s_TextAddOverdrawPipeline;
|
||||
|
||||
boo::ObjToken<boo::IShaderPipeline> CTextSupportShader::s_ImageAlphaPipeline;
|
||||
boo::ObjToken<boo::IShaderPipeline> CTextSupportShader::s_ImageAddPipeline;
|
||||
boo::ObjToken<boo::IShaderPipeline> CTextSupportShader::s_ImageAddOverdrawPipeline;
|
||||
|
||||
hecl::VertexBufferPool<CTextSupportShader::CharacterInstance> CTextSupportShader::s_CharInsts;
|
||||
hecl::VertexBufferPool<CTextSupportShader::ImageInstance> CTextSupportShader::s_ImgInsts;
|
||||
hecl::UniformBufferPool<CTextSupportShader::Uniform> CTextSupportShader::s_Uniforms;
|
||||
|
||||
void CTextSupportShader::Initialize() {
|
||||
s_TextAlphaPipeline = hecl::conv->convert(Shader_CTextSupportShaderAlpha{});
|
||||
s_TextAddPipeline = hecl::conv->convert(Shader_CTextSupportShaderAdd{});
|
||||
s_TextAddOverdrawPipeline = hecl::conv->convert(Shader_CTextSupportShaderAddOverdraw{});
|
||||
s_ImageAlphaPipeline = hecl::conv->convert(Shader_CTextSupportShaderImageAlpha{});
|
||||
s_ImageAddPipeline = hecl::conv->convert(Shader_CTextSupportShaderImageAdd{});
|
||||
s_ImageAddOverdrawPipeline = hecl::conv->convert(Shader_CTextSupportShaderImageAddOverdraw{});
|
||||
}
|
||||
|
||||
void CTextSupportShader::Shutdown() {
|
||||
s_TextAlphaPipeline.reset();
|
||||
s_TextAddPipeline.reset();
|
||||
s_TextAddOverdrawPipeline.reset();
|
||||
s_ImageAlphaPipeline.reset();
|
||||
s_ImageAddPipeline.reset();
|
||||
s_ImageAddOverdrawPipeline.reset();
|
||||
|
||||
s_CharInsts.doDestroy();
|
||||
s_ImgInsts.doDestroy();
|
||||
s_Uniforms.doDestroy();
|
||||
}
|
||||
|
||||
void CTextSupportShader::CharacterInstance::SetMetrics(const CGlyph& glyph, const zeus::CVector2i& offset) {
|
||||
float layer = glyph.GetLayer();
|
||||
|
||||
|
|
|
@ -4,14 +4,11 @@
|
|||
|
||||
#include "Runtime/GuiSys/CGuiWidget.hpp"
|
||||
|
||||
#include <hecl/UniformBufferPool.hpp>
|
||||
#include <hecl/VertexBufferPool.hpp>
|
||||
|
||||
#include <zeus/CColor.hpp>
|
||||
#include <zeus/CMatrix4f.hpp>
|
||||
#include <zeus/CVector2f.hpp>
|
||||
#include <zeus/CVector2i.hpp>
|
||||
#include <zeus/CVector3f.hpp>
|
||||
#include "zeus/CColor.hpp"
|
||||
#include "zeus/CMatrix4f.hpp"
|
||||
#include "zeus/CVector2f.hpp"
|
||||
#include "zeus/CVector2i.hpp"
|
||||
#include "zeus/CVector3f.hpp"
|
||||
|
||||
namespace urde {
|
||||
class CGlyph;
|
||||
|
@ -21,80 +18,26 @@ class CTextRenderBuffer;
|
|||
class CTextSupportShader {
|
||||
friend class CTextRenderBuffer;
|
||||
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_TextAlphaPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_TextAddPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_TextAddOverdrawPipeline;
|
||||
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_ImageAlphaPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_ImageAddPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_ImageAddOverdrawPipeline;
|
||||
|
||||
struct Uniform {
|
||||
zeus::CMatrix4f m_mvp;
|
||||
zeus::CColor m_uniformColor;
|
||||
hsh::float4x4 m_mvp;
|
||||
hsh::float4 m_uniformColor;
|
||||
};
|
||||
|
||||
struct CharacterInstance {
|
||||
std::array<zeus::CVector3f, 4> m_pos;
|
||||
std::array<zeus::CVector3f, 4> m_uv;
|
||||
zeus::CColor m_fontColor;
|
||||
zeus::CColor m_outlineColor;
|
||||
zeus::CColor m_mulColor;
|
||||
std::array<hsh::float3, 4> m_pos;
|
||||
std::array<hsh::float2, 4> m_uv;
|
||||
hsh::float4 m_fontColor;
|
||||
hsh::float4 m_outlineColor;
|
||||
hsh::float4 m_mulColor;
|
||||
void SetMetrics(const CGlyph& glyph, const zeus::CVector2i& offset);
|
||||
};
|
||||
|
||||
struct ImageInstance {
|
||||
std::array<zeus::CVector3f, 4> m_pos;
|
||||
std::array<zeus::CVector2f, 4> m_uv;
|
||||
zeus::CColor m_color;
|
||||
std::array<hsh::float3, 4> m_pos;
|
||||
std::array<hsh::float2, 4> m_uv;
|
||||
hsh::float4 m_color;
|
||||
void SetMetrics(const CFontImageDef& imgDef, const zeus::CVector2i& offset);
|
||||
};
|
||||
|
||||
static hecl::VertexBufferPool<CharacterInstance> s_CharInsts;
|
||||
static hecl::VertexBufferPool<ImageInstance> s_ImgInsts;
|
||||
static hecl::UniformBufferPool<Uniform> s_Uniforms;
|
||||
|
||||
public:
|
||||
static boo::ObjToken<boo::IShaderPipeline> SelectTextPipeline(CGuiWidget::EGuiModelDrawFlags df) {
|
||||
switch (df) {
|
||||
case CGuiWidget::EGuiModelDrawFlags::Shadeless:
|
||||
case CGuiWidget::EGuiModelDrawFlags::Opaque:
|
||||
case CGuiWidget::EGuiModelDrawFlags::Alpha:
|
||||
case CGuiWidget::EGuiModelDrawFlags::AlphaAdditiveOverdraw:
|
||||
return s_TextAlphaPipeline;
|
||||
case CGuiWidget::EGuiModelDrawFlags::Additive:
|
||||
return s_TextAddPipeline;
|
||||
default:
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
static boo::ObjToken<boo::IShaderPipeline> SelectImagePipeline(CGuiWidget::EGuiModelDrawFlags df) {
|
||||
switch (df) {
|
||||
case CGuiWidget::EGuiModelDrawFlags::Shadeless:
|
||||
case CGuiWidget::EGuiModelDrawFlags::Opaque:
|
||||
case CGuiWidget::EGuiModelDrawFlags::Alpha:
|
||||
case CGuiWidget::EGuiModelDrawFlags::AlphaAdditiveOverdraw:
|
||||
return s_ImageAlphaPipeline;
|
||||
case CGuiWidget::EGuiModelDrawFlags::Additive:
|
||||
return s_ImageAddPipeline;
|
||||
default:
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
static boo::ObjToken<boo::IShaderPipeline> GetTextAdditiveOverdrawPipeline() { return s_TextAddOverdrawPipeline; }
|
||||
|
||||
static boo::ObjToken<boo::IShaderPipeline> GetImageAdditiveOverdrawPipeline() { return s_ImageAddOverdrawPipeline; }
|
||||
|
||||
static void UpdateBuffers() {
|
||||
s_CharInsts.updateBuffers();
|
||||
s_ImgInsts.updateBuffers();
|
||||
s_Uniforms.updateBuffers();
|
||||
}
|
||||
|
||||
static void Initialize();
|
||||
static void Shutdown();
|
||||
};
|
||||
|
||||
} // namespace urde
|
||||
|
|
|
@ -5,204 +5,34 @@
|
|||
#include "Runtime/Camera/CCameraFilter.hpp"
|
||||
#include "Runtime/Graphics/CTexture.hpp"
|
||||
|
||||
#include <hecl/Pipeline.hpp>
|
||||
#include "CTexturedQuadFilter.cpp.hshhead"
|
||||
|
||||
namespace urde {
|
||||
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_AlphaPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_AlphaGEqualPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_AlphaGEqualZWritePipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_AlphaLEqualPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_AddPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_AddGEqualPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_AddGEqualZWritePipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_AddLEqualPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_SubtractPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_SubtractGEqualPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_SubtractGEqualZWritePipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_SubtractLEqualPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_MultPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_MultGEqualPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_MultGEqualZWritePipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_MultLEqualPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_InvDstMultPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_InvDstMultGEqualPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_InvDstMultLEqualPipeline;
|
||||
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_AAlphaPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_AAddPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_ASubtractPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_AMultPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_AInvDstMultPipeline;
|
||||
|
||||
void CTexturedQuadFilter::Initialize() {
|
||||
s_AlphaPipeline = hecl::conv->convert(Shader_CTexturedQuadFilterAlpha{});
|
||||
s_AlphaGEqualPipeline = hecl::conv->convert(Shader_CTexturedQuadFilterAlphaGEqual{});
|
||||
s_AlphaGEqualZWritePipeline = hecl::conv->convert(Shader_CTexturedQuadFilterAlphaGEqualZWrite{});
|
||||
s_AlphaLEqualPipeline = hecl::conv->convert(Shader_CTexturedQuadFilterAlphaLEqual{});
|
||||
s_AddPipeline = hecl::conv->convert(Shader_CTexturedQuadFilterAdd{});
|
||||
s_AddGEqualPipeline = hecl::conv->convert(Shader_CTexturedQuadFilterAddGEqual{});
|
||||
s_AddGEqualZWritePipeline = hecl::conv->convert(Shader_CTexturedQuadFilterAddGEqualZWrite{});
|
||||
s_AddLEqualPipeline = hecl::conv->convert(Shader_CTexturedQuadFilterAddLEqual{});
|
||||
s_SubtractPipeline = hecl::conv->convert(Shader_CTexturedQuadFilterSubtract{});
|
||||
s_SubtractGEqualPipeline = hecl::conv->convert(Shader_CTexturedQuadFilterSubtractGEqual{});
|
||||
s_SubtractGEqualZWritePipeline = hecl::conv->convert(Shader_CTexturedQuadFilterSubtractGEqualZWrite{});
|
||||
s_SubtractLEqualPipeline = hecl::conv->convert(Shader_CTexturedQuadFilterSubtractLEqual{});
|
||||
s_MultPipeline = hecl::conv->convert(Shader_CTexturedQuadFilterMult{});
|
||||
s_MultGEqualPipeline = hecl::conv->convert(Shader_CTexturedQuadFilterMultGEqual{});
|
||||
s_MultGEqualZWritePipeline = hecl::conv->convert(Shader_CTexturedQuadFilterMultGEqualZWrite{});
|
||||
s_MultLEqualPipeline = hecl::conv->convert(Shader_CTexturedQuadFilterMultLEqual{});
|
||||
s_InvDstMultPipeline = hecl::conv->convert(Shader_CTexturedQuadFilterInvDstMult{});
|
||||
s_InvDstMultGEqualPipeline = hecl::conv->convert(Shader_CTexturedQuadFilterInvDstMultGEqual{});
|
||||
s_InvDstMultLEqualPipeline = hecl::conv->convert(Shader_CTexturedQuadFilterInvDstMultLEqual{});
|
||||
}
|
||||
|
||||
void CTexturedQuadFilter::Shutdown() {
|
||||
s_AlphaPipeline.reset();
|
||||
s_AlphaGEqualPipeline.reset();
|
||||
s_AlphaGEqualZWritePipeline.reset();
|
||||
s_AlphaLEqualPipeline.reset();
|
||||
s_AddPipeline.reset();
|
||||
s_AddGEqualPipeline.reset();
|
||||
s_AddGEqualZWritePipeline.reset();
|
||||
s_AddLEqualPipeline.reset();
|
||||
s_SubtractPipeline.reset();
|
||||
s_SubtractGEqualPipeline.reset();
|
||||
s_SubtractGEqualZWritePipeline.reset();
|
||||
s_SubtractLEqualPipeline.reset();
|
||||
s_MultPipeline.reset();
|
||||
s_MultGEqualPipeline.reset();
|
||||
s_MultGEqualZWritePipeline.reset();
|
||||
s_MultLEqualPipeline.reset();
|
||||
s_InvDstMultPipeline.reset();
|
||||
s_InvDstMultGEqualPipeline.reset();
|
||||
s_InvDstMultLEqualPipeline.reset();
|
||||
}
|
||||
|
||||
void CTexturedQuadFilterAlpha::Initialize() {
|
||||
s_AAlphaPipeline = hecl::conv->convert(Shader_CTexturedQuadFilterAlphaTexAlpha{});
|
||||
s_AAddPipeline = hecl::conv->convert(Shader_CTexturedQuadFilterAlphaTexAdd{});
|
||||
s_ASubtractPipeline = hecl::conv->convert(Shader_CTexturedQuadFilterAlphaTexSubtract{});
|
||||
s_AMultPipeline = hecl::conv->convert(Shader_CTexturedQuadFilterAlphaTexMult{});
|
||||
s_AInvDstMultPipeline = hecl::conv->convert(Shader_CTexturedQuadFilterAlphaTexInvDstMult{});
|
||||
}
|
||||
|
||||
void CTexturedQuadFilterAlpha::Shutdown() {
|
||||
s_AAlphaPipeline.reset();
|
||||
s_AAddPipeline.reset();
|
||||
s_ASubtractPipeline.reset();
|
||||
s_AMultPipeline.reset();
|
||||
s_AInvDstMultPipeline.reset();
|
||||
}
|
||||
|
||||
static boo::ObjToken<boo::IShaderPipeline> SelectPipeline(EFilterType type, CTexturedQuadFilter::ZTest zTest) {
|
||||
switch (zTest) {
|
||||
case CTexturedQuadFilter::ZTest::GEqual:
|
||||
switch (type) {
|
||||
case EFilterType::Blend:
|
||||
return s_AlphaGEqualPipeline;
|
||||
case EFilterType::Add:
|
||||
return s_AddGEqualPipeline;
|
||||
case EFilterType::Subtract:
|
||||
return s_SubtractGEqualPipeline;
|
||||
case EFilterType::Multiply:
|
||||
return s_MultGEqualPipeline;
|
||||
default:
|
||||
break;
|
||||
template <EFilterType Type, bool TexAlpha>
|
||||
struct CTexturedQuadFilterPipeline : FilterPipeline<Type> {
|
||||
CTexturedQuadFilterPipeline(hsh::vertex_buffer<CTexturedQuadFilter::Vert> vbo,
|
||||
hsh::uniform_buffer<CTexturedQuadFilter::Uniform> uniBuf, hsh::texture2d tex) {
|
||||
this->position = hsh::float4(vbo->m_pos, 1.f);
|
||||
if constexpr (TexAlpha) {
|
||||
this->color_out[0] = uniBuf->m_color * tex.sample_bias<float>(vbo->m_uv, uniBuf->m_lod, {});
|
||||
} else {
|
||||
this->color_out[0] =
|
||||
uniBuf->m_color * hsh::float4(tex.sample_bias<float>(vbo->m_uv, uniBuf->m_lod, {}).xyz(), 1.f);
|
||||
}
|
||||
break;
|
||||
case CTexturedQuadFilter::ZTest::GEqualZWrite:
|
||||
switch (type) {
|
||||
case EFilterType::Blend:
|
||||
return s_AlphaGEqualZWritePipeline;
|
||||
case EFilterType::Add:
|
||||
return s_AddGEqualZWritePipeline;
|
||||
case EFilterType::Subtract:
|
||||
return s_SubtractGEqualZWritePipeline;
|
||||
case EFilterType::Multiply:
|
||||
return s_MultGEqualZWritePipeline;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case CTexturedQuadFilter::ZTest::LEqual:
|
||||
switch (type) {
|
||||
case EFilterType::Blend:
|
||||
return s_AlphaLEqualPipeline;
|
||||
case EFilterType::Add:
|
||||
return s_AddLEqualPipeline;
|
||||
case EFilterType::Subtract:
|
||||
return s_SubtractLEqualPipeline;
|
||||
case EFilterType::Multiply:
|
||||
return s_MultLEqualPipeline;
|
||||
case EFilterType::InvDstMultiply:
|
||||
return s_InvDstMultLEqualPipeline;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
switch (type) {
|
||||
case EFilterType::Blend:
|
||||
return s_AlphaPipeline;
|
||||
case EFilterType::Add:
|
||||
return s_AddPipeline;
|
||||
case EFilterType::Subtract:
|
||||
return s_SubtractPipeline;
|
||||
case EFilterType::Multiply:
|
||||
return s_MultPipeline;
|
||||
case EFilterType::InvDstMultiply:
|
||||
return s_InvDstMultPipeline;
|
||||
default:
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
static boo::ObjToken<boo::IShaderPipeline> SelectAlphaPipeline(EFilterType type) {
|
||||
switch (type) {
|
||||
case EFilterType::Blend:
|
||||
return s_AAlphaPipeline;
|
||||
case EFilterType::Add:
|
||||
return s_AAddPipeline;
|
||||
case EFilterType::Subtract:
|
||||
return s_ASubtractPipeline;
|
||||
case EFilterType::Multiply:
|
||||
return s_AMultPipeline;
|
||||
case EFilterType::InvDstMultiply:
|
||||
return s_AInvDstMultPipeline;
|
||||
default:
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
CTexturedQuadFilter::CTexturedQuadFilter(const boo::ObjToken<boo::ITexture>& tex) : m_booTex(tex) {
|
||||
m_flipRect = CGraphics::g_BooFactory->platform() == boo::IGraphicsDataFactory::Platform::Vulkan;
|
||||
}
|
||||
|
||||
CTexturedQuadFilter::CTexturedQuadFilter(EFilterType type, const boo::ObjToken<boo::ITexture>& tex, ZTest ztest)
|
||||
: m_booTex(tex), m_zTest(ztest) {
|
||||
m_flipRect = CGraphics::g_BooFactory->platform() == boo::IGraphicsDataFactory::Platform::Vulkan;
|
||||
tex->setClampMode(boo::TextureClampMode::ClampToEdge);
|
||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
||||
m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, 32, 16);
|
||||
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
|
||||
|
||||
const std::array<boo::ObjToken<boo::IGraphicsBuffer>, 1> bufs{m_uniBuf.get()};
|
||||
const std::array<boo::PipelineStage, 1> stages{boo::PipelineStage::Vertex};
|
||||
const std::array<boo::ObjToken<boo::ITexture>, 1> texs{m_booTex.get()};
|
||||
m_dataBind =
|
||||
ctx.newShaderDataBinding(SelectPipeline(type, m_zTest), m_vbo.get(), nullptr, nullptr, bufs.size(), bufs.data(),
|
||||
stages.data(), nullptr, nullptr, texs.size(), texs.data(), nullptr, nullptr);
|
||||
return true;
|
||||
} BooTrace);
|
||||
template <typename Tex>
|
||||
CTexturedQuadFilter::CTexturedQuadFilter(EFilterType type, Tex tex, ZTest ztest)
|
||||
: m_zTest(ztest) {
|
||||
m_vbo = hsh::create_dynamic_vertex_buffer<Vert>(16);
|
||||
m_uniBuf = hsh::create_dynamic_uniform_buffer<Uniform>();
|
||||
m_dataBind.hsh_bind(CTexturedQuadFilterPipeline<type, false>(m_vbo.get(), m_uniBuf.get(), tex));
|
||||
}
|
||||
|
||||
CTexturedQuadFilter::CTexturedQuadFilter(EFilterType type, TLockedToken<CTexture> tex, ZTest ztest)
|
||||
: CTexturedQuadFilter(type, (tex ? tex->GetBooTexture() : nullptr), ztest) {
|
||||
m_flipRect = CGraphics::g_BooFactory->platform() == boo::IGraphicsDataFactory::Platform::Vulkan;
|
||||
: CTexturedQuadFilter(type, (tex ? tex->GetBooTexture() : hsh::texture2d{}), ztest) {
|
||||
m_tex = tex;
|
||||
}
|
||||
|
||||
|
@ -215,24 +45,16 @@ void CTexturedQuadFilter::draw(const zeus::CColor& color, float uvScale, const z
|
|||
{{1.f, 0.f, z}, {uvScale, 0.f}},
|
||||
{{1.f, 1.f, z}, {uvScale, uvScale}},
|
||||
}};
|
||||
m_vbo->load(verts.data(), sizeof(verts));
|
||||
m_vbo.load(verts);
|
||||
|
||||
if (!m_flipRect) {
|
||||
m_uniform.m_matrix[0][0] = rect.size.x() * 2.f;
|
||||
m_uniform.m_matrix[1][1] = rect.size.y() * 2.f;
|
||||
m_uniform.m_matrix[3][0] = rect.position.x() * 2.f - 1.f;
|
||||
m_uniform.m_matrix[3][1] = rect.position.y() * 2.f - 1.f;
|
||||
} else {
|
||||
m_uniform.m_matrix[0][0] = rect.size.x() * 2.f;
|
||||
m_uniform.m_matrix[1][1] = rect.size.y() * -2.f;
|
||||
m_uniform.m_matrix[3][0] = rect.position.x() * 2.f - 1.f;
|
||||
m_uniform.m_matrix[3][1] = rect.position.y() * -2.f + 1.f;
|
||||
}
|
||||
m_uniform.m_matrix[0][0] = rect.size.x() * 2.f;
|
||||
m_uniform.m_matrix[1][1] = rect.size.y() * 2.f;
|
||||
m_uniform.m_matrix[3][0] = rect.position.x() * 2.f - 1.f;
|
||||
m_uniform.m_matrix[3][1] = rect.position.y() * 2.f - 1.f;
|
||||
m_uniform.m_color = color;
|
||||
m_uniBuf->load(&m_uniform, sizeof(m_uniform));
|
||||
m_uniBuf.load(m_uniform);
|
||||
|
||||
CGraphics::SetShaderDataBinding(m_dataBind);
|
||||
CGraphics::DrawArray(0, 4);
|
||||
m_dataBind.draw(0, 4);
|
||||
}
|
||||
|
||||
void CTexturedQuadFilter::drawCropped(const zeus::CColor& color, float uvScale) {
|
||||
|
@ -249,27 +71,25 @@ void CTexturedQuadFilter::drawCropped(const zeus::CColor& color, float uvScale)
|
|||
{{1.f, -1.f, 0.f}, {(xBias + xFac) * uvScale, yBias * uvScale}},
|
||||
{{1.f, 1.f, 0.f}, {(xBias + xFac) * uvScale, (yBias + yFac) * uvScale}},
|
||||
}};
|
||||
m_vbo->load(verts.data(), sizeof(verts));
|
||||
m_vbo.load(verts);
|
||||
|
||||
m_uniform.m_color = color;
|
||||
m_uniBuf->load(&m_uniform, sizeof(m_uniform));
|
||||
m_uniBuf.load(m_uniform);
|
||||
|
||||
CGraphics::SetShaderDataBinding(m_dataBind);
|
||||
CGraphics::DrawArray(0, 4);
|
||||
m_dataBind.draw(0, 4);
|
||||
}
|
||||
|
||||
void CTexturedQuadFilter::drawVerts(const zeus::CColor& color, const Vert verts[4], float lod) {
|
||||
void CTexturedQuadFilter::drawVerts(const zeus::CColor& color, const std::array<Vert, 4>& verts, float lod) {
|
||||
SCOPED_GRAPHICS_DEBUG_GROUP("CTexturedQuadFilter::drawVerts", zeus::skMagenta);
|
||||
|
||||
m_vbo->load(verts, sizeof(Vert) * 4);
|
||||
m_vbo.load(verts);
|
||||
|
||||
m_uniform.m_matrix = CGraphics::GetPerspectiveProjectionMatrix(true) * CGraphics::g_GXModelView.toMatrix4f();
|
||||
m_uniform.m_color = color;
|
||||
m_uniform.m_lod = lod;
|
||||
m_uniBuf->load(&m_uniform, sizeof(m_uniform));
|
||||
m_uniBuf.load(m_uniform);
|
||||
|
||||
CGraphics::SetShaderDataBinding(m_dataBind);
|
||||
CGraphics::DrawArray(0, 4);
|
||||
m_dataBind.draw(0, 4);
|
||||
}
|
||||
|
||||
void CTexturedQuadFilter::DrawFilter(EFilterShape shape, const zeus::CColor& color, float t) {
|
||||
|
@ -278,9 +98,7 @@ void CTexturedQuadFilter::DrawFilter(EFilterShape shape, const zeus::CColor& col
|
|||
m_uniform.m_matrix = zeus::CMatrix4f();
|
||||
m_uniform.m_lod = 0.f;
|
||||
m_uniform.m_color = color;
|
||||
m_uniBuf->load(&m_uniform, sizeof(m_uniform));
|
||||
|
||||
CGraphics::SetShaderDataBinding(m_dataBind);
|
||||
m_uniBuf.load(m_uniform);
|
||||
|
||||
if (shape == EFilterShape::FullscreenQuarters) {
|
||||
const std::array<Vert, 16> QuadVerts{{
|
||||
|
@ -305,11 +123,11 @@ void CTexturedQuadFilter::DrawFilter(EFilterShape shape, const zeus::CColor& col
|
|||
{{0.f, 1.f, 0.f}, {0.f, t}},
|
||||
{{0.f, 0.f, 0.f}, {0.f, 0.f}},
|
||||
}};
|
||||
m_vbo->load(QuadVerts.data(), sizeof(QuadVerts));
|
||||
CGraphics::DrawArray(0, 4);
|
||||
CGraphics::DrawArray(4, 4);
|
||||
CGraphics::DrawArray(8, 4);
|
||||
CGraphics::DrawArray(12, 4);
|
||||
m_vbo.load(QuadVerts);
|
||||
m_dataBind.draw(0, 4);
|
||||
m_dataBind.draw(4, 4);
|
||||
m_dataBind.draw(8, 4);
|
||||
m_dataBind.draw(12, 4);
|
||||
} else {
|
||||
const std::array<Vert, 4> FullscreenVerts{{
|
||||
{{-1.f, -1.f, 0.f}, {0.f, 0.f}},
|
||||
|
@ -317,31 +135,22 @@ void CTexturedQuadFilter::DrawFilter(EFilterShape shape, const zeus::CColor& col
|
|||
{{1.f, -1.f, 0.f}, {t, 0.f}},
|
||||
{{1.f, 1.f, 0.f}, {t, t}},
|
||||
}};
|
||||
m_vbo->load(FullscreenVerts.data(), sizeof(FullscreenVerts));
|
||||
CGraphics::DrawArray(0, FullscreenVerts.size());
|
||||
m_vbo.load(FullscreenVerts);
|
||||
m_dataBind.draw(0, FullscreenVerts.size());
|
||||
}
|
||||
}
|
||||
|
||||
const zeus::CRectangle CTexturedQuadFilter::DefaultRect = {0.f, 0.f, 1.f, 1.f};
|
||||
|
||||
CTexturedQuadFilterAlpha::CTexturedQuadFilterAlpha(EFilterType type, const boo::ObjToken<boo::ITexture>& tex)
|
||||
: CTexturedQuadFilter(tex) {
|
||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
||||
m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, 32, 4);
|
||||
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
|
||||
|
||||
const std::array<boo::ObjToken<boo::IGraphicsBuffer>, 1> bufs{m_uniBuf.get()};
|
||||
constexpr std::array<boo::PipelineStage, 1> stages{boo::PipelineStage::Vertex};
|
||||
const std::array<boo::ObjToken<boo::ITexture>, 1> texs{m_booTex.get()};
|
||||
m_dataBind =
|
||||
ctx.newShaderDataBinding(SelectAlphaPipeline(type), m_vbo.get(), nullptr, nullptr, bufs.size(), bufs.data(),
|
||||
stages.data(), nullptr, nullptr, texs.size(), texs.data(), nullptr, nullptr);
|
||||
return true;
|
||||
} BooTrace);
|
||||
template <typename Tex>
|
||||
CTexturedQuadFilterAlpha::CTexturedQuadFilterAlpha(EFilterType type, Tex tex) {
|
||||
m_vbo = hsh::create_dynamic_vertex_buffer<Vert>(16);
|
||||
m_uniBuf = hsh::create_dynamic_uniform_buffer<Uniform>();
|
||||
m_dataBind.hsh_bind_alpha(CTexturedQuadFilterPipeline<type, true>(m_vbo.get(), m_uniBuf.get(), tex));
|
||||
}
|
||||
|
||||
CTexturedQuadFilterAlpha::CTexturedQuadFilterAlpha(EFilterType type, TLockedToken<CTexture> tex)
|
||||
: CTexturedQuadFilterAlpha(type, (tex ? tex->GetBooTexture() : nullptr)) {
|
||||
: CTexturedQuadFilterAlpha(type, (tex ? tex->GetBooTexture() : hsh::texture2d{})) {
|
||||
m_tex = tex;
|
||||
}
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue