mirror of https://github.com/AxioDL/metaforce.git
Start wiring up wgpu+winit
This commit is contained in:
parent
5491fd75cf
commit
e48435f11e
|
@ -0,0 +1,36 @@
|
||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Launch",
|
||||||
|
"type": "cppdbg",
|
||||||
|
"request": "launch",
|
||||||
|
// Resolved by CMake Tools:
|
||||||
|
"program": "${command:cmake.launchTargetPath}",
|
||||||
|
"args": [],
|
||||||
|
"stopAtEntry": false,
|
||||||
|
"cwd": "${workspaceFolder}",
|
||||||
|
"environment": [
|
||||||
|
{
|
||||||
|
// add the directory where our target was built to the PATHs
|
||||||
|
// it gets resolved by CMake Tools:
|
||||||
|
"name": "PATH",
|
||||||
|
"value": "$PATH:${command:cmake.launchTargetDirectory}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "OTHER_VALUE",
|
||||||
|
"value": "Something something"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"externalConsole": true,
|
||||||
|
"MIMode": "gdb",
|
||||||
|
"setupCommands": [
|
||||||
|
{
|
||||||
|
"description": "Enable pretty-printing for gdb",
|
||||||
|
"text": "-enable-pretty-printing",
|
||||||
|
"ignoreFailures": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -469,7 +469,7 @@ function(shaderc out)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
include(hecl/ApplicationTools.cmake)
|
include(hecl/ApplicationTools.cmake)
|
||||||
add_subdirectory(Shaders)
|
#add_subdirectory(Shaders)
|
||||||
add_subdirectory(imgui)
|
add_subdirectory(imgui)
|
||||||
add_subdirectory(extern/libSquish EXCLUDE_FROM_ALL)
|
add_subdirectory(extern/libSquish EXCLUDE_FROM_ALL)
|
||||||
add_subdirectory(extern/libpng EXCLUDE_FROM_ALL)
|
add_subdirectory(extern/libpng EXCLUDE_FROM_ALL)
|
||||||
|
@ -481,21 +481,21 @@ target_include_directories(hecl-light PRIVATE ${CMAKE_SOURCE_DIR})
|
||||||
target_link_libraries(hecl-full PRIVATE zeus nod)
|
target_link_libraries(hecl-full PRIVATE zeus nod)
|
||||||
target_link_libraries(hecl-light PRIVATE zeus nod)
|
target_link_libraries(hecl-light PRIVATE zeus nod)
|
||||||
|
|
||||||
bintoc(CModelShaders.common.glsl.cpp Shaders/CModelShaders.common.glsl CMODELSHADERS_COMMON_GLSL)
|
#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.vert.glsl.cpp Shaders/CModelShaders.vert.glsl CMODELSHADERS_VERT_GLSL)
|
||||||
bintoc(CModelShaders.frag.glsl.cpp Shaders/CModelShaders.frag.glsl CMODELSHADERS_FRAG_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.common.hlsl.cpp Shaders/CModelShaders.common.hlsl CMODELSHADERS_COMMON_HLSL)
|
||||||
bintoc(CModelShaders.vert.hlsl.cpp Shaders/CModelShaders.vert.hlsl CMODELSHADERS_VERT_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.frag.hlsl.cpp Shaders/CModelShaders.frag.hlsl CMODELSHADERS_FRAG_HLSL)
|
||||||
bintoc(CModelShaders.common.metal.cpp Shaders/CModelShaders.common.metal CMODELSHADERS_COMMON_METAL)
|
#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.vert.metal.cpp Shaders/CModelShaders.vert.metal CMODELSHADERS_VERT_METAL)
|
||||||
bintoc(CModelShaders.frag.metal.cpp Shaders/CModelShaders.frag.metal CMODELSHADERS_FRAG_METAL)
|
#bintoc(CModelShaders.frag.metal.cpp Shaders/CModelShaders.frag.metal CMODELSHADERS_FRAG_METAL)
|
||||||
add_library(CModelShaders
|
#add_library(CModelShaders
|
||||||
CModelShaders.common.glsl.cpp CModelShaders.vert.glsl.cpp CModelShaders.frag.glsl.cpp
|
# 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.hlsl.cpp CModelShaders.vert.hlsl.cpp CModelShaders.frag.hlsl.cpp
|
||||||
CModelShaders.common.metal.cpp CModelShaders.vert.metal.cpp CModelShaders.frag.metal.cpp)
|
# CModelShaders.common.metal.cpp CModelShaders.vert.metal.cpp CModelShaders.frag.metal.cpp)
|
||||||
target_link_libraries(CModelShaders PUBLIC zeus)
|
#target_link_libraries(CModelShaders PUBLIC zeus)
|
||||||
target_link_libraries(shader_CModelShaders PUBLIC CModelShaders)
|
#target_link_libraries(shader_CModelShaders PUBLIC CModelShaders)
|
||||||
|
|
||||||
if(NOT TARGET atdna)
|
if(NOT TARGET atdna)
|
||||||
# Import native atdna if cross-compiling
|
# Import native atdna if cross-compiling
|
||||||
|
@ -517,12 +517,13 @@ add_subdirectory(extern/jbus EXCLUDE_FROM_ALL)
|
||||||
set(JBUS_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/extern/jbus/include)
|
set(JBUS_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/extern/jbus/include)
|
||||||
|
|
||||||
add_subdirectory(NESEmulator EXCLUDE_FROM_ALL)
|
add_subdirectory(NESEmulator EXCLUDE_FROM_ALL)
|
||||||
|
add_subdirectory(Graphics)
|
||||||
add_subdirectory(Runtime)
|
add_subdirectory(Runtime)
|
||||||
add_subdirectory(mpcksum EXCLUDE_FROM_ALL)
|
add_subdirectory(mpcksum EXCLUDE_FROM_ALL)
|
||||||
add_subdirectory(gbalink EXCLUDE_FROM_ALL)
|
add_subdirectory(gbalink EXCLUDE_FROM_ALL)
|
||||||
add_subdirectory(visigen)
|
#add_subdirectory(visigen)
|
||||||
|
|
||||||
add_dependencies(hecl visigen)
|
#add_dependencies(hecl visigen)
|
||||||
|
|
||||||
if (NOT WINDOWS_STORE AND NOT NX)
|
if (NOT WINDOWS_STORE AND NOT NX)
|
||||||
if (APPLE AND EXISTS /opt/local/libexec/qt5)
|
if (APPLE AND EXISTS /opt/local/libexec/qt5)
|
||||||
|
@ -552,7 +553,7 @@ endif()
|
||||||
configure_file(${CMAKE_SOURCE_DIR}/version.h.in ${CMAKE_BINARY_DIR}/version.h)
|
configure_file(${CMAKE_SOURCE_DIR}/version.h.in ${CMAKE_BINARY_DIR}/version.h)
|
||||||
|
|
||||||
# Packaging logic
|
# Packaging logic
|
||||||
list(APPEND BINARY_TARGETS metaforce hecl visigen)
|
list(APPEND BINARY_TARGETS metaforce hecl) # visigen
|
||||||
set(DSYM_ONLY_TARGETS "")
|
set(DSYM_ONLY_TARGETS "")
|
||||||
if (TARGET crashpad_handler)
|
if (TARGET crashpad_handler)
|
||||||
list(APPEND BINARY_TARGETS crashpad_handler)
|
list(APPEND BINARY_TARGETS crashpad_handler)
|
||||||
|
|
|
@ -74,7 +74,7 @@ add_library(AssetNameMapNull
|
||||||
|
|
||||||
get_target_property(HECL_INCLUDES hecl-full INCLUDE_DIRECTORIES)
|
get_target_property(HECL_INCLUDES hecl-full INCLUDE_DIRECTORIES)
|
||||||
target_include_directories(RetroDataSpec PUBLIC ${HECL_INCLUDES} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR})
|
target_include_directories(RetroDataSpec PUBLIC ${HECL_INCLUDES} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR})
|
||||||
target_link_libraries(RetroDataSpec PUBLIC amuse zeus nod squish ${PNG_LIBRARIES} ${ZLIB_LIBRARIES} lzokay logvisor)
|
target_link_libraries(RetroDataSpec PUBLIC amuse zeus nod squish ${PNG_LIBRARIES} ${ZLIB_LIBRARIES} lzokay logvisor aurora)
|
||||||
if (COMMAND add_sanitizers)
|
if (COMMAND add_sanitizers)
|
||||||
add_sanitizers(RetroDataSpec)
|
add_sanitizers(RetroDataSpec)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
# Rust
|
||||||
|
target/
|
||||||
|
**/*.rs.bk
|
||||||
|
generated/
|
||||||
|
|
||||||
|
# cargo-mobile
|
||||||
|
.cargo/
|
||||||
|
/gen
|
||||||
|
|
||||||
|
# macOS
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
|
# JetBrains
|
||||||
|
.idea
|
||||||
|
|
||||||
|
# Generated SPIR-V
|
||||||
|
*.spv
|
|
@ -0,0 +1,42 @@
|
||||||
|
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
|
set(CARGO_CMD cargo build --verbose)
|
||||||
|
set(TARGET_DIR "debug")
|
||||||
|
else ()
|
||||||
|
set(CARGO_CMD cargo build --release --verbose)
|
||||||
|
set(TARGET_DIR "release")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
if(USE_LTO)
|
||||||
|
set(RUST_FLAGS "-Clinker-plugin-lto" "-Clinker=clang" "-Clink-arg=-fuse-ld=lld")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(AURORA_LIB "${CMAKE_CURRENT_BINARY_DIR}/${TARGET_DIR}/libaurora.a")
|
||||||
|
|
||||||
|
set(AURORA_CXX "${CMAKE_CURRENT_BINARY_DIR}/aurora.cpp")
|
||||||
|
set(AURORA_SHADERS_CXX "${CMAKE_CURRENT_BINARY_DIR}/aurora_shaders.cpp")
|
||||||
|
set(AURORA_IMGUI_CXX "${CMAKE_CURRENT_BINARY_DIR}/aurora_imgui.cpp")
|
||||||
|
add_library(aurora STATIC ${AURORA_CXX} ${AURORA_SHADERS_CXX})
|
||||||
|
target_include_directories(aurora PRIVATE ../Runtime)
|
||||||
|
target_include_directories(aurora PUBLIC include ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT ${AURORA_CXX} ${AURORA_SHADERS_CXX} ${AURORA_IMGUI_CXX} ${AURORA_LIB} #__no_exist
|
||||||
|
COMMAND CARGO_TARGET_DIR=${CMAKE_CURRENT_BINARY_DIR} RUSTFLAGS="${RUST_FLAGS}" ${CARGO_CMD}
|
||||||
|
COMMAND cp ${CMAKE_CURRENT_BINARY_DIR}/cxxbridge/aurora/src/lib.rs.cc ${AURORA_CXX}
|
||||||
|
COMMAND cp ${CMAKE_CURRENT_BINARY_DIR}/cxxbridge/aurora/src/lib.rs.h ${CMAKE_CURRENT_BINARY_DIR}/aurora.h
|
||||||
|
COMMAND cp ${CMAKE_CURRENT_BINARY_DIR}/cxxbridge/aurora/src/shaders/mod.rs.cc ${AURORA_SHADERS_CXX}
|
||||||
|
COMMAND cp ${CMAKE_CURRENT_BINARY_DIR}/cxxbridge/aurora/src/shaders/mod.rs.h ${CMAKE_CURRENT_BINARY_DIR}/aurora_shaders.h
|
||||||
|
COMMAND cp ${CMAKE_CURRENT_BINARY_DIR}/cxxbridge/aurora/src/imgui.rs.cc ${AURORA_IMGUI_CXX}
|
||||||
|
COMMAND cp ${CMAKE_CURRENT_BINARY_DIR}/cxxbridge/aurora/src/imgui.rs.h ${CMAKE_CURRENT_BINARY_DIR}/aurora_imgui.h
|
||||||
|
DEPENDS src/lib.rs
|
||||||
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
)
|
||||||
|
add_custom_target(
|
||||||
|
always_run ALL
|
||||||
|
DEPENDS __no_exist
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(aurora pthread dl ${AURORA_LIB} zeus)
|
||||||
|
|
||||||
|
add_test(NAME aurora_test
|
||||||
|
COMMAND cargo test
|
||||||
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,75 @@
|
||||||
|
[package]
|
||||||
|
name = "aurora"
|
||||||
|
version = "0.0.1"
|
||||||
|
authors = ["Luke Street <luke@street.dev>"]
|
||||||
|
edition = "2021"
|
||||||
|
license = "MIT"
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
crate-type = ["staticlib"]
|
||||||
|
|
||||||
|
#[[bin]]
|
||||||
|
#name = "metaforce"
|
||||||
|
#path = "src/main.rs"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
cxx = "1.0.60"
|
||||||
|
web-sys = "0.3.55"
|
||||||
|
env_logger = "0.9.0"
|
||||||
|
mobile-entry-point = "0.1.1"
|
||||||
|
pollster = "0.2.4"
|
||||||
|
binread = { version = "2.2.0", features = ['const_generics'] }
|
||||||
|
modular-bitfield = "0.11.2"
|
||||||
|
num-traits = "0.2.14"
|
||||||
|
num_enum = "0.5.5"
|
||||||
|
bytemuck = "1.7.3"
|
||||||
|
bytemuck_derive = "1.0.1"
|
||||||
|
log = "0.4.14"
|
||||||
|
log-panics = "2.0.0"
|
||||||
|
cgmath = "0.18.0"
|
||||||
|
smallvec = "1.7.0"
|
||||||
|
scopeguard = "1.1.0"
|
||||||
|
twox-hash = "1.6.2"
|
||||||
|
winit = "0.26.0"
|
||||||
|
|
||||||
|
[dependencies.imgui]
|
||||||
|
git = "https://github.com/imgui-rs/imgui-rs"
|
||||||
|
rev = "55a76370466953d5c044afc123330d0262b50e17"
|
||||||
|
[dependencies.imgui-winit-support]
|
||||||
|
git = "https://github.com/imgui-rs/imgui-rs"
|
||||||
|
rev = "55a76370466953d5c044afc123330d0262b50e17"
|
||||||
|
default-features = false
|
||||||
|
features = ["winit-26"]
|
||||||
|
[patch.'https://github.com/imgui-rs/imgui-rs']
|
||||||
|
imgui-sys = { path = "../imgui-sys" }
|
||||||
|
[patch.crates-io]
|
||||||
|
imgui-sys = { path = "../imgui-sys" }
|
||||||
|
|
||||||
|
[dependencies.wgpu]
|
||||||
|
#path = "../../wgpu/wgpu"
|
||||||
|
git = "https://github.com/gfx-rs/wgpu"
|
||||||
|
rev = "39b7a8a202c21da43035ec8dd5570a58cf4e8ef1"
|
||||||
|
features = ["spirv"]
|
||||||
|
|
||||||
|
#[patch.'https://github.com/gfx-rs/naga']
|
||||||
|
#naga = { path = "../../naga" }
|
||||||
|
|
||||||
|
[build-dependencies]
|
||||||
|
#naga = { path = "../../naga", features = ['spv-out', 'wgsl-in'] }
|
||||||
|
naga = { git = "https://github.com/gfx-rs/naga", rev = "8df5421", features = ['spv-out', 'wgsl-in'] }
|
||||||
|
bytemuck = "1.7.3"
|
||||||
|
cxx-build = "1.0.60"
|
||||||
|
bindgen = "0.59.2"
|
||||||
|
|
||||||
|
[target.'cfg(target_os = "android")'.dependencies]
|
||||||
|
android_logger = "0.10.1"
|
||||||
|
ndk-glue = "0.5.0"
|
||||||
|
|
||||||
|
[target.'cfg(not(target_os = "android"))'.dependencies]
|
||||||
|
wgpu-subscriber = "0.1.0"
|
||||||
|
|
||||||
|
[target.'cfg(target_family = "wasm")'.dependencies]
|
||||||
|
console_error_panic_hook = "0.1.7"
|
||||||
|
console_log = "0.2.0"
|
||||||
|
wasm-bindgen-futures = "0.4.28"
|
||||||
|
#features = ["web-sys"]
|
|
@ -0,0 +1,47 @@
|
||||||
|
fn main() {
|
||||||
|
let zeus_include = std::path::PathBuf::from(format!(
|
||||||
|
"{}/../extern/zeus/include",
|
||||||
|
std::env::var("CARGO_MANIFEST_DIR").unwrap()
|
||||||
|
))
|
||||||
|
.canonicalize()
|
||||||
|
.unwrap();
|
||||||
|
let imgui_include = std::path::PathBuf::from(format!(
|
||||||
|
"{}/../extern/imgui",
|
||||||
|
std::env::var("CARGO_MANIFEST_DIR").unwrap()
|
||||||
|
))
|
||||||
|
.canonicalize()
|
||||||
|
.unwrap();
|
||||||
|
let imgui_engine_include = std::path::PathBuf::from(format!(
|
||||||
|
"{}/../imgui",
|
||||||
|
std::env::var("CARGO_MANIFEST_DIR").unwrap()
|
||||||
|
))
|
||||||
|
.canonicalize()
|
||||||
|
.unwrap();
|
||||||
|
// let include_dir = include_path.to_string_lossy();
|
||||||
|
// let bindings = bindgen::Builder::default()
|
||||||
|
// .header(format!("{}/zeus/CVector3f.hpp", include_dir))
|
||||||
|
// .clang_arg(format!("-I{}", include_dir))
|
||||||
|
// .parse_callbacks(Box::new(bindgen::CargoCallbacks))
|
||||||
|
// .generate()
|
||||||
|
// .expect("Unable to generate bindings");
|
||||||
|
// let out_path = std::path::PathBuf::from(std::env::var("OUT_DIR").unwrap());
|
||||||
|
// bindings.write_to_file(out_path.join("zeus.rs")).expect("Couldn't write bindings!");
|
||||||
|
|
||||||
|
cxx_build::bridge("src/lib.rs")
|
||||||
|
.include("include")
|
||||||
|
.include(zeus_include.clone())
|
||||||
|
.compile("aurora");
|
||||||
|
println!("cargo:rerun-if-changed=src/lib.rs");
|
||||||
|
cxx_build::bridge("src/shaders/mod.rs")
|
||||||
|
.include("include")
|
||||||
|
.include(zeus_include.clone())
|
||||||
|
.compile("aurora_shaders");
|
||||||
|
println!("cargo:rerun-if-changed=src/shaders/mod.rs");
|
||||||
|
cxx_build::bridge("src/imgui.rs")
|
||||||
|
.include("include")
|
||||||
|
.include(zeus_include.clone())
|
||||||
|
.include(imgui_include.clone())
|
||||||
|
.include(imgui_engine_include.clone())
|
||||||
|
.compile("aurora_imgui");
|
||||||
|
println!("cargo:rerun-if-changed=src/imgui.rs");
|
||||||
|
}
|
|
@ -0,0 +1,48 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
#include <type_traits>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
namespace aurora {
|
||||||
|
struct WindowSize;
|
||||||
|
|
||||||
|
struct App;
|
||||||
|
struct AppDelegate {
|
||||||
|
AppDelegate() = default;
|
||||||
|
virtual ~AppDelegate() noexcept = default;
|
||||||
|
AppDelegate(const AppDelegate&) = delete;
|
||||||
|
AppDelegate& operator=(const AppDelegate&) = delete;
|
||||||
|
AppDelegate(AppDelegate&&) = delete;
|
||||||
|
AppDelegate& operator=(AppDelegate&&) = delete;
|
||||||
|
|
||||||
|
virtual void onAppLaunched() noexcept = 0;
|
||||||
|
virtual bool onAppIdle(float dt) noexcept = 0;
|
||||||
|
virtual void onAppDraw() noexcept = 0;
|
||||||
|
virtual void onAppPostDraw() noexcept = 0;
|
||||||
|
virtual void onAppExiting() noexcept = 0;
|
||||||
|
|
||||||
|
// virtual void resized([[maybe_unused]] const WindowSize& rect, [[maybe_unused]] bool sync) noexcept {}
|
||||||
|
// virtual void mouseDown([[maybe_unused]] const SWindowCoord& coord, [[maybe_unused]] EMouseButton button,
|
||||||
|
// [[maybe_unused]] EModifierKey mods) noexcept {}
|
||||||
|
// virtual void mouseUp([[maybe_unused]] const SWindowCoord& coord, [[maybe_unused]] EMouseButton button,
|
||||||
|
// [[maybe_unused]] EModifierKey mods) noexcept {}
|
||||||
|
// virtual void mouseMove([[maybe_unused]] const SWindowCoord& coord) noexcept {}
|
||||||
|
// virtual void mouseEnter([[maybe_unused]] const SWindowCoord& coord) noexcept {}
|
||||||
|
// virtual void mouseLeave([[maybe_unused]] const SWindowCoord& coord) noexcept {}
|
||||||
|
// virtual void scroll([[maybe_unused]] const SWindowCoord& coord, [[maybe_unused]] const SScrollDelta& scroll) noexcept {}
|
||||||
|
//
|
||||||
|
// virtual void touchDown([[maybe_unused]] const STouchCoord& coord, [[maybe_unused]] uintptr_t tid) noexcept {}
|
||||||
|
// virtual void touchUp([[maybe_unused]] const STouchCoord& coord, [[maybe_unused]] uintptr_t tid) noexcept {}
|
||||||
|
// virtual void touchMove([[maybe_unused]] const STouchCoord& coord, [[maybe_unused]] uintptr_t tid) noexcept {}
|
||||||
|
//
|
||||||
|
// virtual void charKeyDown([[maybe_unused]] unsigned long charCode, [[maybe_unused]] EModifierKey mods,
|
||||||
|
// [[maybe_unused]] bool isRepeat) noexcept {}
|
||||||
|
// virtual void charKeyUp([[maybe_unused]] unsigned long charCode, [[maybe_unused]] EModifierKey mods) noexcept {}
|
||||||
|
// virtual void specialKeyDown([[maybe_unused]] ESpecialKey key, [[maybe_unused]] EModifierKey mods,
|
||||||
|
// [[maybe_unused]] bool isRepeat) noexcept {}
|
||||||
|
// virtual void specialKeyUp([[maybe_unused]] ESpecialKey key, [[maybe_unused]] EModifierKey mods) noexcept {}
|
||||||
|
// virtual void modKeyDown([[maybe_unused]] EModifierKey mod, [[maybe_unused]] bool isRepeat) noexcept {}
|
||||||
|
// virtual void modKeyUp([[maybe_unused]] EModifierKey mod) noexcept {}
|
||||||
|
};
|
||||||
|
} // namespace aurora
|
|
@ -0,0 +1,9 @@
|
||||||
|
#include "aurora.hpp"
|
||||||
|
|
||||||
|
namespace aurora {
|
||||||
|
void App_onAppLaunched(AppDelegate& cb) noexcept;
|
||||||
|
bool App_onAppIdle(AppDelegate& cb, float dt) noexcept;
|
||||||
|
void App_onAppDraw(AppDelegate& cb) noexcept;
|
||||||
|
void App_onAppPostDraw(AppDelegate& cb) noexcept;
|
||||||
|
void App_onAppExiting(AppDelegate& cb) noexcept;
|
||||||
|
} // namespace aurora
|
|
@ -0,0 +1,9 @@
|
||||||
|
#include "include/lib.hpp"
|
||||||
|
|
||||||
|
namespace aurora {
|
||||||
|
void App_onAppLaunched(AppDelegate& cb) noexcept { return cb.onAppLaunched(); }
|
||||||
|
bool App_onAppIdle(AppDelegate& cb, float dt) noexcept { return cb.onAppIdle(dt); }
|
||||||
|
void App_onAppDraw(AppDelegate& cb) noexcept { cb.onAppDraw(); }
|
||||||
|
void App_onAppPostDraw(AppDelegate& cb) noexcept { cb.onAppPostDraw(); }
|
||||||
|
void App_onAppExiting(AppDelegate& cb) noexcept { cb.onAppExiting(); }
|
||||||
|
} // namespace aurora
|
|
@ -0,0 +1,8 @@
|
||||||
|
fn_single_line = true
|
||||||
|
group_imports = "StdExternalCrate"
|
||||||
|
imports_granularity = "Crate"
|
||||||
|
overflow_delimited_expr = true
|
||||||
|
reorder_impl_items = true
|
||||||
|
use_field_init_shorthand = true
|
||||||
|
use_small_heuristics = "Max"
|
||||||
|
where_single_line = true
|
|
@ -0,0 +1,194 @@
|
||||||
|
use std::{num::NonZeroU8, sync::Arc};
|
||||||
|
|
||||||
|
use pollster::block_on;
|
||||||
|
|
||||||
|
#[derive(Clone)]
|
||||||
|
pub(crate) struct GraphicsConfig {
|
||||||
|
pub(crate) color_format: wgpu::TextureFormat,
|
||||||
|
pub(crate) depth_format: wgpu::TextureFormat,
|
||||||
|
pub(crate) texture_anistropy: Option<NonZeroU8>,
|
||||||
|
pub(crate) msaa_samples: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct DeviceHolder {
|
||||||
|
pub(crate) instance: wgpu::Instance,
|
||||||
|
pub(crate) surface: wgpu::Surface,
|
||||||
|
pub(crate) adapter: wgpu::Adapter,
|
||||||
|
pub(crate) backend: wgpu::Backend,
|
||||||
|
pub(crate) device: Arc<wgpu::Device>,
|
||||||
|
pub(crate) queue: Arc<wgpu::Queue>,
|
||||||
|
pub(crate) config: GraphicsConfig,
|
||||||
|
pub(crate) surface_config: wgpu::SurfaceConfiguration,
|
||||||
|
pub(crate) framebuffer: TextureWithSampler,
|
||||||
|
pub(crate) depth: TextureWithSampler,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) struct TextureWithSampler {
|
||||||
|
pub(crate) texture: wgpu::Texture,
|
||||||
|
pub(crate) view: wgpu::TextureView,
|
||||||
|
pub(crate) sampler: wgpu::Sampler,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn create_render_texture(
|
||||||
|
device: &wgpu::Device,
|
||||||
|
config: &wgpu::SurfaceConfiguration,
|
||||||
|
graphics_config: &GraphicsConfig,
|
||||||
|
) -> TextureWithSampler {
|
||||||
|
let texture = device.create_texture(&wgpu::TextureDescriptor {
|
||||||
|
label: Some("Render texture"),
|
||||||
|
size: wgpu::Extent3d {
|
||||||
|
width: config.width,
|
||||||
|
height: config.height,
|
||||||
|
depth_or_array_layers: 1,
|
||||||
|
},
|
||||||
|
mip_level_count: 1,
|
||||||
|
sample_count: graphics_config.msaa_samples,
|
||||||
|
dimension: wgpu::TextureDimension::D2,
|
||||||
|
format: graphics_config.color_format,
|
||||||
|
usage: wgpu::TextureUsages::RENDER_ATTACHMENT,
|
||||||
|
});
|
||||||
|
let view = texture.create_view(&wgpu::TextureViewDescriptor::default());
|
||||||
|
let sampler = device.create_sampler(&wgpu::SamplerDescriptor {
|
||||||
|
label: Some("Render sampler"),
|
||||||
|
address_mode_u: wgpu::AddressMode::ClampToEdge,
|
||||||
|
address_mode_v: wgpu::AddressMode::ClampToEdge,
|
||||||
|
address_mode_w: wgpu::AddressMode::ClampToEdge,
|
||||||
|
mag_filter: wgpu::FilterMode::Linear,
|
||||||
|
min_filter: wgpu::FilterMode::Linear,
|
||||||
|
mipmap_filter: wgpu::FilterMode::Linear,
|
||||||
|
lod_min_clamp: 0.0,
|
||||||
|
lod_max_clamp: f32::MAX,
|
||||||
|
compare: None,
|
||||||
|
anisotropy_clamp: None,
|
||||||
|
border_color: None,
|
||||||
|
});
|
||||||
|
TextureWithSampler { texture, view, sampler }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn create_depth_texture(
|
||||||
|
device: &wgpu::Device,
|
||||||
|
config: &wgpu::SurfaceConfiguration,
|
||||||
|
graphics_config: &GraphicsConfig,
|
||||||
|
) -> TextureWithSampler {
|
||||||
|
let texture = device.create_texture(&wgpu::TextureDescriptor {
|
||||||
|
label: Some("Depth texture"),
|
||||||
|
size: wgpu::Extent3d {
|
||||||
|
width: config.width,
|
||||||
|
height: config.height,
|
||||||
|
depth_or_array_layers: 1,
|
||||||
|
},
|
||||||
|
mip_level_count: 1,
|
||||||
|
sample_count: graphics_config.msaa_samples,
|
||||||
|
dimension: wgpu::TextureDimension::D2,
|
||||||
|
format: graphics_config.depth_format,
|
||||||
|
usage: wgpu::TextureUsages::RENDER_ATTACHMENT,
|
||||||
|
});
|
||||||
|
let view = texture.create_view(&wgpu::TextureViewDescriptor::default());
|
||||||
|
let sampler = device.create_sampler(&wgpu::SamplerDescriptor {
|
||||||
|
label: Some("Depth sampler"),
|
||||||
|
address_mode_u: wgpu::AddressMode::ClampToEdge,
|
||||||
|
address_mode_v: wgpu::AddressMode::ClampToEdge,
|
||||||
|
address_mode_w: wgpu::AddressMode::ClampToEdge,
|
||||||
|
mag_filter: wgpu::FilterMode::Linear,
|
||||||
|
min_filter: wgpu::FilterMode::Linear,
|
||||||
|
mipmap_filter: wgpu::FilterMode::Linear,
|
||||||
|
lod_min_clamp: 0.0,
|
||||||
|
lod_max_clamp: f32::MAX,
|
||||||
|
compare: None,
|
||||||
|
anisotropy_clamp: None,
|
||||||
|
border_color: None,
|
||||||
|
});
|
||||||
|
TextureWithSampler { texture, view, sampler }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn initialize_gpu(window: &winit::window::Window) -> DeviceHolder {
|
||||||
|
log::info!("Creating wgpu instance");
|
||||||
|
let instance = wgpu::Instance::new(wgpu::Backends::all());
|
||||||
|
let surface = unsafe { instance.create_surface(window) };
|
||||||
|
let adapter = block_on(instance.request_adapter(&wgpu::RequestAdapterOptions {
|
||||||
|
power_preference: wgpu::PowerPreference::HighPerformance,
|
||||||
|
compatible_surface: Some(&surface),
|
||||||
|
force_fallback_adapter: false,
|
||||||
|
}))
|
||||||
|
.expect("Failed to find an appropriate adapter");
|
||||||
|
let best_limits = adapter.limits();
|
||||||
|
let backend = adapter.get_info().backend;
|
||||||
|
#[cfg(any(target_os = "android", target_os = "ios"))]
|
||||||
|
let needs_denorm = true;
|
||||||
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
|
let _needs_denorm = backend == wgpu::Backend::Gl;
|
||||||
|
|
||||||
|
let required_features = if backend == wgpu::Backend::Vulkan {
|
||||||
|
wgpu::Features::SPIRV_SHADER_PASSTHROUGH
|
||||||
|
} else {
|
||||||
|
wgpu::Features::empty()
|
||||||
|
};
|
||||||
|
let optional_features = wgpu::Features::TEXTURE_COMPRESSION_BC
|
||||||
|
| wgpu::Features::ADDRESS_MODE_CLAMP_TO_BORDER
|
||||||
|
| required_features;
|
||||||
|
log::info!("Requesting device with features: {:?}", optional_features);
|
||||||
|
let limits = wgpu::Limits::downlevel_defaults()
|
||||||
|
.using_resolution(best_limits.clone())
|
||||||
|
.using_alignment(best_limits);
|
||||||
|
let (device, queue) = block_on(adapter.request_device(
|
||||||
|
&wgpu::DeviceDescriptor {
|
||||||
|
label: Some("Device with optional features"),
|
||||||
|
features: optional_features,
|
||||||
|
limits: limits.clone(),
|
||||||
|
},
|
||||||
|
None,
|
||||||
|
))
|
||||||
|
.unwrap_or_else(|_| {
|
||||||
|
log::warn!("Failed... requesting device with no features");
|
||||||
|
block_on(adapter.request_device(
|
||||||
|
&wgpu::DeviceDescriptor {
|
||||||
|
label: Some("Device without optional features"),
|
||||||
|
features: required_features,
|
||||||
|
limits,
|
||||||
|
},
|
||||||
|
None,
|
||||||
|
))
|
||||||
|
.expect("Failed to create device")
|
||||||
|
});
|
||||||
|
log::info!("Successfully created device");
|
||||||
|
|
||||||
|
let mut swapchain_format = surface.get_preferred_format(&adapter).unwrap();
|
||||||
|
if backend != wgpu::Backend::Gl {
|
||||||
|
swapchain_format = match swapchain_format {
|
||||||
|
wgpu::TextureFormat::Rgba8UnormSrgb => wgpu::TextureFormat::Rgba8Unorm,
|
||||||
|
wgpu::TextureFormat::Bgra8UnormSrgb => wgpu::TextureFormat::Bgra8Unorm,
|
||||||
|
_ => swapchain_format,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
let graphics_config = GraphicsConfig {
|
||||||
|
color_format: swapchain_format,
|
||||||
|
depth_format: wgpu::TextureFormat::Depth32Float,
|
||||||
|
texture_anistropy: NonZeroU8::new(16),
|
||||||
|
msaa_samples: 4,
|
||||||
|
};
|
||||||
|
|
||||||
|
let size = window.inner_size();
|
||||||
|
let surface_config = wgpu::SurfaceConfiguration {
|
||||||
|
usage: wgpu::TextureUsages::RENDER_ATTACHMENT,
|
||||||
|
format: swapchain_format,
|
||||||
|
width: size.width,
|
||||||
|
height: size.height,
|
||||||
|
present_mode: wgpu::PresentMode::Fifo,
|
||||||
|
};
|
||||||
|
surface.configure(&device, &surface_config);
|
||||||
|
let depth = create_depth_texture(&device, &surface_config, &graphics_config);
|
||||||
|
let framebuffer = create_render_texture(&device, &surface_config, &graphics_config);
|
||||||
|
|
||||||
|
DeviceHolder {
|
||||||
|
instance,
|
||||||
|
surface,
|
||||||
|
adapter,
|
||||||
|
backend,
|
||||||
|
device: Arc::new(device),
|
||||||
|
queue: Arc::new(queue),
|
||||||
|
config: graphics_config,
|
||||||
|
surface_config,
|
||||||
|
framebuffer,
|
||||||
|
depth,
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,80 @@
|
||||||
|
use crate::{gpu::DeviceHolder, imgui_backend};
|
||||||
|
|
||||||
|
#[cxx::bridge(namespace = "metaforce")]
|
||||||
|
mod ffi {
|
||||||
|
unsafe extern "C++" {
|
||||||
|
include!("ImGuiEngine.hpp");
|
||||||
|
pub(crate) fn ImGuiEngine_Initialize(scale: f32);
|
||||||
|
pub(crate) fn ImGuiEngine_AddTextures(state: &mut ImGuiState, device: &DeviceHolder);
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "Rust" {
|
||||||
|
type ImGuiState;
|
||||||
|
type DeviceHolder;
|
||||||
|
fn ImGuiEngine_AddTexture(
|
||||||
|
state: &mut ImGuiState,
|
||||||
|
device: &DeviceHolder,
|
||||||
|
width: u32,
|
||||||
|
height: u32,
|
||||||
|
data: &[u8],
|
||||||
|
) -> usize;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct ImGuiState {
|
||||||
|
pub(crate) context: imgui::Context,
|
||||||
|
pub(crate) platform: imgui_winit_support::WinitPlatform,
|
||||||
|
pub(crate) backend: imgui_backend::Renderer,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn initialize_imgui(window: &winit::window::Window, gpu: &DeviceHolder) -> ImGuiState {
|
||||||
|
let hidpi_factor = window.scale_factor();
|
||||||
|
let mut imgui = imgui::Context::create();
|
||||||
|
let mut platform = imgui_winit_support::WinitPlatform::init(&mut imgui);
|
||||||
|
platform.attach_window(imgui.io_mut(), &window, imgui_winit_support::HiDpiMode::Default);
|
||||||
|
imgui.set_ini_filename(None);
|
||||||
|
imgui.io_mut().font_global_scale = (1.0 / hidpi_factor) as f32;
|
||||||
|
|
||||||
|
unsafe {
|
||||||
|
ffi::ImGuiEngine_Initialize(hidpi_factor as f32);
|
||||||
|
}
|
||||||
|
|
||||||
|
let renderer_config = if gpu.backend == wgpu::Backend::Vulkan {
|
||||||
|
imgui_backend::RendererConfig::new_spv_srgb()
|
||||||
|
} else {
|
||||||
|
imgui_backend::RendererConfig::new_srgb()
|
||||||
|
};
|
||||||
|
let imgui_backend = imgui_backend::Renderer::new(
|
||||||
|
&mut imgui,
|
||||||
|
&gpu.device,
|
||||||
|
&gpu.queue,
|
||||||
|
imgui_backend::RendererConfig {
|
||||||
|
texture_format: gpu.config.color_format,
|
||||||
|
depth_format: Some(gpu.config.depth_format),
|
||||||
|
sample_count: gpu.config.msaa_samples,
|
||||||
|
..renderer_config
|
||||||
|
},
|
||||||
|
);
|
||||||
|
let mut state = ImGuiState { context: imgui, platform, backend: imgui_backend };
|
||||||
|
unsafe {
|
||||||
|
ffi::ImGuiEngine_AddTextures(&mut state, &gpu);
|
||||||
|
}
|
||||||
|
state
|
||||||
|
}
|
||||||
|
|
||||||
|
fn ImGuiEngine_AddTexture(
|
||||||
|
state: &mut ImGuiState,
|
||||||
|
gpu: &DeviceHolder,
|
||||||
|
width: u32,
|
||||||
|
height: u32,
|
||||||
|
data: &[u8],
|
||||||
|
) -> usize {
|
||||||
|
let texture =
|
||||||
|
imgui_backend::Texture::new(&gpu.device, &state.backend, imgui_backend::TextureConfig {
|
||||||
|
size: wgpu::Extent3d { width, height, depth_or_array_layers: 1 },
|
||||||
|
format: Some(wgpu::TextureFormat::Rgba8Unorm),
|
||||||
|
..Default::default()
|
||||||
|
});
|
||||||
|
texture.write(&gpu.queue, data, width, height);
|
||||||
|
state.backend.textures.insert(texture).id()
|
||||||
|
}
|
|
@ -0,0 +1,53 @@
|
||||||
|
struct Uniforms {
|
||||||
|
u_Matrix: mat4x4<f32>;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct VertexInput {
|
||||||
|
[[location(0)]] a_Pos: vec2<f32>;
|
||||||
|
[[location(1)]] a_UV: vec2<f32>;
|
||||||
|
[[location(2)]] a_Color: vec4<f32>;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct VertexOutput {
|
||||||
|
[[location(0)]] v_UV: vec2<f32>;
|
||||||
|
[[location(1)]] v_Color: vec4<f32>;
|
||||||
|
[[builtin(position)]] v_Position: vec4<f32>;
|
||||||
|
};
|
||||||
|
|
||||||
|
[[group(0), binding(0)]]
|
||||||
|
var<uniform> uniforms: Uniforms;
|
||||||
|
|
||||||
|
[[stage(vertex)]]
|
||||||
|
fn vs_main(in: VertexInput) -> VertexOutput {
|
||||||
|
var out: VertexOutput;
|
||||||
|
out.v_UV = in.a_UV;
|
||||||
|
out.v_Color = in.a_Color;
|
||||||
|
out.v_Position = uniforms.u_Matrix * vec4<f32>(in.a_Pos.xy, 0.0, 1.0);
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[group(1), binding(0)]]
|
||||||
|
var u_Texture: texture_2d<f32>;
|
||||||
|
[[group(1), binding(1)]]
|
||||||
|
var u_Sampler: sampler;
|
||||||
|
|
||||||
|
fn srgb_to_linear(srgb: vec4<f32>) -> vec4<f32> {
|
||||||
|
let color_srgb = srgb.rgb;
|
||||||
|
let selector = ceil(color_srgb - 0.04045); // 0 if under value, 1 if over
|
||||||
|
let under = color_srgb / 12.92;
|
||||||
|
let over = pow((color_srgb + 0.055) / 1.055, vec3<f32>(2.4));
|
||||||
|
let result = mix(under, over, selector);
|
||||||
|
return vec4<f32>(result, srgb.a);
|
||||||
|
}
|
||||||
|
|
||||||
|
[[stage(fragment)]]
|
||||||
|
fn fs_main_linear(in: VertexOutput) -> [[location(0)]] vec4<f32> {
|
||||||
|
let color = srgb_to_linear(in.v_Color);
|
||||||
|
return color * textureSample(u_Texture, u_Sampler, in.v_UV);
|
||||||
|
}
|
||||||
|
|
||||||
|
[[stage(fragment)]]
|
||||||
|
fn fs_main_srgb(in: VertexOutput) -> [[location(0)]] vec4<f32> {
|
||||||
|
let color = in.v_Color;
|
||||||
|
return color * textureSample(u_Texture, u_Sampler, in.v_UV);
|
||||||
|
}
|
|
@ -0,0 +1,659 @@
|
||||||
|
use std::{borrow::BorrowMut, error::Error, fmt, mem::size_of, num::NonZeroU32};
|
||||||
|
|
||||||
|
use imgui::{
|
||||||
|
Context, DrawCmd::Elements, DrawData, DrawIdx, DrawList, DrawVert, TextureId, Textures,
|
||||||
|
};
|
||||||
|
use smallvec::SmallVec;
|
||||||
|
use wgpu::{
|
||||||
|
util::{BufferInitDescriptor, DeviceExt},
|
||||||
|
*,
|
||||||
|
};
|
||||||
|
|
||||||
|
static VS_ENTRY_POINT: &str = "vs_main";
|
||||||
|
static FS_ENTRY_POINT_LINEAR: &str = "fs_main_linear";
|
||||||
|
static FS_ENTRY_POINT_SRGB: &str = "fs_main_srgb";
|
||||||
|
|
||||||
|
pub type RendererResult<T> = Result<T, RendererError>;
|
||||||
|
|
||||||
|
#[repr(transparent)]
|
||||||
|
#[derive(Debug, Copy, Clone)]
|
||||||
|
struct DrawVertPod(DrawVert);
|
||||||
|
|
||||||
|
unsafe impl bytemuck::Zeroable for DrawVertPod {}
|
||||||
|
|
||||||
|
unsafe impl bytemuck::Pod for DrawVertPod {}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug)]
|
||||||
|
pub enum RendererError {
|
||||||
|
BadTexture(TextureId),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl fmt::Display for RendererError {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
match *self {
|
||||||
|
RendererError::BadTexture(id) => {
|
||||||
|
write!(f, "imgui render error: bad texture id '{}'", id.id())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Error for RendererError {}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
enum ShaderStage {
|
||||||
|
Vertex,
|
||||||
|
Fragment,
|
||||||
|
Compute,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Config for creating a texture.
|
||||||
|
///
|
||||||
|
/// Uses the builder pattern.
|
||||||
|
#[derive(Clone)]
|
||||||
|
pub struct TextureConfig<'a> {
|
||||||
|
/// The size of the texture.
|
||||||
|
pub size: Extent3d,
|
||||||
|
/// An optional label for the texture used for debugging.
|
||||||
|
pub label: Option<&'a str>,
|
||||||
|
/// The format of the texture, if not set uses the format from the renderer.
|
||||||
|
pub format: Option<TextureFormat>,
|
||||||
|
/// The usage of the texture.
|
||||||
|
pub usage: TextureUsages,
|
||||||
|
/// The mip level of the texture.
|
||||||
|
pub mip_level_count: u32,
|
||||||
|
/// The sample count of the texture.
|
||||||
|
pub sample_count: u32,
|
||||||
|
/// The dimension of the texture.
|
||||||
|
pub dimension: TextureDimension,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> Default for TextureConfig<'a> {
|
||||||
|
/// Create a new texture config.
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
size: Extent3d { width: 0, height: 0, depth_or_array_layers: 1 },
|
||||||
|
label: None,
|
||||||
|
format: None,
|
||||||
|
usage: TextureUsages::TEXTURE_BINDING | TextureUsages::COPY_DST,
|
||||||
|
mip_level_count: 1,
|
||||||
|
sample_count: 1,
|
||||||
|
dimension: TextureDimension::D2,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A container for a bindable texture.
|
||||||
|
pub struct Texture {
|
||||||
|
texture: wgpu::Texture,
|
||||||
|
view: wgpu::TextureView,
|
||||||
|
bind_group: BindGroup,
|
||||||
|
size: Extent3d,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Texture {
|
||||||
|
/// Create a `Texture` from its raw parts.
|
||||||
|
pub fn from_raw_parts(
|
||||||
|
texture: wgpu::Texture,
|
||||||
|
view: wgpu::TextureView,
|
||||||
|
bind_group: BindGroup,
|
||||||
|
size: Extent3d,
|
||||||
|
) -> Self {
|
||||||
|
Self { texture, view, bind_group, size }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Create a new GPU texture width the specified `config`.
|
||||||
|
pub fn new(device: &Device, renderer: &Renderer, config: TextureConfig) -> Self {
|
||||||
|
// Create the wgpu texture.
|
||||||
|
let texture = device.create_texture(&TextureDescriptor {
|
||||||
|
label: config.label,
|
||||||
|
size: config.size,
|
||||||
|
mip_level_count: config.mip_level_count,
|
||||||
|
sample_count: config.sample_count,
|
||||||
|
dimension: config.dimension,
|
||||||
|
format: config.format.unwrap_or(renderer.config.texture_format),
|
||||||
|
usage: config.usage,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Extract the texture view.
|
||||||
|
let view = texture.create_view(&TextureViewDescriptor::default());
|
||||||
|
|
||||||
|
// Create the texture sampler.
|
||||||
|
let sampler = device.create_sampler(&SamplerDescriptor {
|
||||||
|
label: Some("imgui-wgpu sampler"),
|
||||||
|
address_mode_u: AddressMode::ClampToEdge,
|
||||||
|
address_mode_v: AddressMode::ClampToEdge,
|
||||||
|
address_mode_w: AddressMode::ClampToEdge,
|
||||||
|
mag_filter: FilterMode::Linear,
|
||||||
|
min_filter: FilterMode::Linear,
|
||||||
|
mipmap_filter: FilterMode::Linear,
|
||||||
|
lod_min_clamp: 0.0,
|
||||||
|
lod_max_clamp: f32::MAX,
|
||||||
|
compare: None,
|
||||||
|
anisotropy_clamp: None,
|
||||||
|
border_color: None,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Create the texture bind group from the layout.
|
||||||
|
let bind_group = device.create_bind_group(&BindGroupDescriptor {
|
||||||
|
label: config.label,
|
||||||
|
layout: &renderer.texture_layout,
|
||||||
|
entries: &[
|
||||||
|
BindGroupEntry { binding: 0, resource: BindingResource::TextureView(&view) },
|
||||||
|
BindGroupEntry { binding: 1, resource: BindingResource::Sampler(&sampler) },
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
Self { texture, view, bind_group, size: config.size }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Write `data` to the texture.
|
||||||
|
///
|
||||||
|
/// - `data`: 32-bit RGBA bitmap data.
|
||||||
|
/// - `width`: The width of the source bitmap (`data`) in pixels.
|
||||||
|
/// - `height`: The height of the source bitmap (`data`) in pixels.
|
||||||
|
pub fn write(&self, queue: &Queue, data: &[u8], width: u32, height: u32) {
|
||||||
|
queue.write_texture(
|
||||||
|
// destination (sub)texture
|
||||||
|
ImageCopyTexture {
|
||||||
|
texture: &self.texture,
|
||||||
|
mip_level: 0,
|
||||||
|
origin: Origin3d { x: 0, y: 0, z: 0 },
|
||||||
|
aspect: TextureAspect::All,
|
||||||
|
},
|
||||||
|
// source bitmap data
|
||||||
|
data,
|
||||||
|
// layout of the source bitmap
|
||||||
|
ImageDataLayout {
|
||||||
|
offset: 0,
|
||||||
|
bytes_per_row: NonZeroU32::new(width * 4),
|
||||||
|
rows_per_image: NonZeroU32::new(height),
|
||||||
|
},
|
||||||
|
// size of the source bitmap
|
||||||
|
Extent3d { width, height, depth_or_array_layers: 1 },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The width of the texture in pixels.
|
||||||
|
pub fn width(&self) -> u32 { self.size.width }
|
||||||
|
|
||||||
|
/// The height of the texture in pixels.
|
||||||
|
pub fn height(&self) -> u32 { self.size.height }
|
||||||
|
|
||||||
|
/// The depth of the texture.
|
||||||
|
pub fn depth(&self) -> u32 { self.size.depth_or_array_layers }
|
||||||
|
|
||||||
|
/// The size of the texture in pixels.
|
||||||
|
pub fn size(&self) -> Extent3d { self.size }
|
||||||
|
|
||||||
|
/// The underlying `wgpu::Texture`.
|
||||||
|
pub fn texture(&self) -> &wgpu::Texture { &self.texture }
|
||||||
|
|
||||||
|
/// The `wgpu::TextureView` of the underlying texture.
|
||||||
|
pub fn view(&self) -> &wgpu::TextureView { &self.view }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct CombinedShader<'s> {
|
||||||
|
pub shader: ShaderModuleDescriptor<'s>,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct SeparateShaders<'s> {
|
||||||
|
pub vertex_shader: ShaderModuleDescriptorSpirV<'s>,
|
||||||
|
pub fragment_shader: ShaderModuleDescriptorSpirV<'s>,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub enum ShaderType<'s> {
|
||||||
|
None,
|
||||||
|
Combined(CombinedShader<'s>),
|
||||||
|
Separate(SeparateShaders<'s>),
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Configuration for the renderer.
|
||||||
|
pub struct RendererConfig<'s> {
|
||||||
|
pub texture_format: TextureFormat,
|
||||||
|
pub depth_format: Option<TextureFormat>,
|
||||||
|
pub sample_count: u32,
|
||||||
|
pub shader: ShaderType<'s>,
|
||||||
|
pub vertex_shader_entry_point: String,
|
||||||
|
pub fragment_shader_entry_point: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl RendererConfig<'_> {
|
||||||
|
/// Create a new renderer config with custom shaders.
|
||||||
|
pub fn with_combined_shaders<'s>(
|
||||||
|
shader: ShaderModuleDescriptor<'s>,
|
||||||
|
fragment_shader_entry_point: &str,
|
||||||
|
) -> RendererConfig<'s> {
|
||||||
|
RendererConfig {
|
||||||
|
texture_format: TextureFormat::Rgba8Unorm,
|
||||||
|
depth_format: None,
|
||||||
|
sample_count: 1,
|
||||||
|
shader: ShaderType::Combined(CombinedShader { shader }),
|
||||||
|
vertex_shader_entry_point: VS_ENTRY_POINT.to_string(),
|
||||||
|
fragment_shader_entry_point: fragment_shader_entry_point.to_string(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Create a new renderer config with custom shaders.
|
||||||
|
pub fn with_separate_shaders<'s>(
|
||||||
|
vertex_shader: ShaderModuleDescriptorSpirV<'s>,
|
||||||
|
fragment_shader: ShaderModuleDescriptorSpirV<'s>,
|
||||||
|
fragment_shader_entry_point: &str,
|
||||||
|
) -> RendererConfig<'s> {
|
||||||
|
RendererConfig {
|
||||||
|
texture_format: TextureFormat::Rgba8Unorm,
|
||||||
|
depth_format: None,
|
||||||
|
sample_count: 1,
|
||||||
|
shader: ShaderType::Separate(SeparateShaders { vertex_shader, fragment_shader }),
|
||||||
|
vertex_shader_entry_point: VS_ENTRY_POINT.to_string(),
|
||||||
|
fragment_shader_entry_point: fragment_shader_entry_point.to_string(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for RendererConfig<'_> {
|
||||||
|
/// Create a new renderer config with precompiled default shaders outputting linear color.
|
||||||
|
///
|
||||||
|
/// If you write to a Bgra8UnormSrgb framebuffer, this is what you want.
|
||||||
|
fn default() -> Self { Self::new() }
|
||||||
|
}
|
||||||
|
|
||||||
|
impl RendererConfig<'_> {
|
||||||
|
/// Create a new renderer config with precompiled default shaders outputting linear color.
|
||||||
|
///
|
||||||
|
/// If you write to a Bgra8UnormSrgb framebuffer, this is what you want.
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Self::with_combined_shaders(include_wgsl!("imgui.wgsl"), FS_ENTRY_POINT_LINEAR)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Create a new renderer config with precompiled default shaders outputting srgb color.
|
||||||
|
///
|
||||||
|
/// If you write to a Bgra8Unorm framebuffer, this is what you want.
|
||||||
|
pub fn new_srgb() -> Self {
|
||||||
|
Self::with_combined_shaders(include_wgsl!("imgui.wgsl"), FS_ENTRY_POINT_SRGB)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Create a new renderer config with precompiled default shaders outputting linear color.
|
||||||
|
///
|
||||||
|
/// If you write to a Bgra8UnormSrgb framebuffer, this is what you want.
|
||||||
|
pub fn new_spv() -> Self {
|
||||||
|
Self::with_separate_shaders(
|
||||||
|
include_spirv_raw!("imgui_vs_main.spv"),
|
||||||
|
include_spirv_raw!("imgui_fs_main_linear.spv"),
|
||||||
|
FS_ENTRY_POINT_LINEAR,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Create a new renderer config with precompiled default shaders outputting srgb color.
|
||||||
|
///
|
||||||
|
/// If you write to a Bgra8Unorm framebuffer, this is what you want.
|
||||||
|
pub fn new_spv_srgb() -> Self {
|
||||||
|
Self::with_separate_shaders(
|
||||||
|
include_spirv_raw!("imgui_vs_main.spv"),
|
||||||
|
include_spirv_raw!("imgui_fs_main_srgb.spv"),
|
||||||
|
FS_ENTRY_POINT_SRGB,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct Renderer {
|
||||||
|
pipeline: RenderPipeline,
|
||||||
|
uniform_buffer: Buffer,
|
||||||
|
uniform_bind_group: BindGroup,
|
||||||
|
/// Textures of the font atlas and all images.
|
||||||
|
pub textures: Textures<Texture>,
|
||||||
|
texture_layout: BindGroupLayout,
|
||||||
|
index_buffers: SmallVec<[Buffer; 4]>,
|
||||||
|
vertex_buffers: SmallVec<[Buffer; 4]>,
|
||||||
|
config: RendererConfig<'static>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Renderer {
|
||||||
|
/// Create an entirely new imgui wgpu renderer.
|
||||||
|
pub fn new(
|
||||||
|
imgui: &mut Context,
|
||||||
|
device: &Device,
|
||||||
|
queue: &Queue,
|
||||||
|
config: RendererConfig,
|
||||||
|
) -> Self {
|
||||||
|
let RendererConfig {
|
||||||
|
texture_format,
|
||||||
|
depth_format,
|
||||||
|
sample_count,
|
||||||
|
shader,
|
||||||
|
vertex_shader_entry_point,
|
||||||
|
fragment_shader_entry_point,
|
||||||
|
} = config;
|
||||||
|
|
||||||
|
// Load shaders.
|
||||||
|
let shader1: Option<wgpu::ShaderModule>;
|
||||||
|
let shader2: Option<wgpu::ShaderModule>;
|
||||||
|
let (vs, fs) = match shader {
|
||||||
|
ShaderType::Combined(d) => {
|
||||||
|
shader1 = Some(device.create_shader_module(&d.shader));
|
||||||
|
let r = shader1.as_ref().unwrap();
|
||||||
|
(r, r)
|
||||||
|
}
|
||||||
|
ShaderType::Separate(d) => unsafe {
|
||||||
|
shader1 = Some(device.create_shader_module_spirv(&d.vertex_shader));
|
||||||
|
shader2 = Some(device.create_shader_module_spirv(&d.fragment_shader));
|
||||||
|
(shader1.as_ref().unwrap(), shader2.as_ref().unwrap())
|
||||||
|
},
|
||||||
|
ShaderType::None => panic!(),
|
||||||
|
};
|
||||||
|
|
||||||
|
// Create the uniform matrix buffer.
|
||||||
|
let size = 64;
|
||||||
|
let uniform_buffer = device.create_buffer(&BufferDescriptor {
|
||||||
|
label: Some("imgui-wgpu uniform buffer"),
|
||||||
|
size,
|
||||||
|
usage: BufferUsages::UNIFORM | BufferUsages::COPY_DST,
|
||||||
|
mapped_at_creation: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Create the uniform matrix buffer bind group layout.
|
||||||
|
let uniform_layout = device.create_bind_group_layout(&BindGroupLayoutDescriptor {
|
||||||
|
label: None,
|
||||||
|
entries: &[BindGroupLayoutEntry {
|
||||||
|
binding: 0,
|
||||||
|
visibility: wgpu::ShaderStages::VERTEX,
|
||||||
|
ty: BindingType::Buffer {
|
||||||
|
ty: BufferBindingType::Uniform,
|
||||||
|
has_dynamic_offset: false,
|
||||||
|
min_binding_size: None,
|
||||||
|
},
|
||||||
|
count: None,
|
||||||
|
}],
|
||||||
|
});
|
||||||
|
|
||||||
|
// Create the uniform matrix buffer bind group.
|
||||||
|
let uniform_bind_group = device.create_bind_group(&BindGroupDescriptor {
|
||||||
|
label: Some("imgui-wgpu bind group"),
|
||||||
|
layout: &uniform_layout,
|
||||||
|
entries: &[BindGroupEntry { binding: 0, resource: uniform_buffer.as_entire_binding() }],
|
||||||
|
});
|
||||||
|
|
||||||
|
// Create the texture layout for further usage.
|
||||||
|
let texture_layout = device.create_bind_group_layout(&BindGroupLayoutDescriptor {
|
||||||
|
label: Some("imgui-wgpu bind group layout"),
|
||||||
|
entries: &[
|
||||||
|
BindGroupLayoutEntry {
|
||||||
|
binding: 0,
|
||||||
|
visibility: wgpu::ShaderStages::FRAGMENT,
|
||||||
|
ty: BindingType::Texture {
|
||||||
|
multisampled: false,
|
||||||
|
sample_type: TextureSampleType::Float { filterable: true },
|
||||||
|
view_dimension: TextureViewDimension::D2,
|
||||||
|
},
|
||||||
|
count: None,
|
||||||
|
},
|
||||||
|
BindGroupLayoutEntry {
|
||||||
|
binding: 1,
|
||||||
|
visibility: wgpu::ShaderStages::FRAGMENT,
|
||||||
|
ty: BindingType::Sampler(wgpu::SamplerBindingType::Filtering),
|
||||||
|
count: None,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
// Create the render pipeline layout.
|
||||||
|
let pipeline_layout = device.create_pipeline_layout(&PipelineLayoutDescriptor {
|
||||||
|
label: Some("imgui-wgpu pipeline layout"),
|
||||||
|
bind_group_layouts: &[&uniform_layout, &texture_layout],
|
||||||
|
push_constant_ranges: &[],
|
||||||
|
});
|
||||||
|
|
||||||
|
// Create the render pipeline.
|
||||||
|
// Create the render pipeline.
|
||||||
|
let pipeline = device.create_render_pipeline(&RenderPipelineDescriptor {
|
||||||
|
label: Some("imgui-wgpu pipeline"),
|
||||||
|
layout: Some(&pipeline_layout),
|
||||||
|
vertex: VertexState {
|
||||||
|
module: vs,
|
||||||
|
entry_point: &vertex_shader_entry_point,
|
||||||
|
buffers: &[VertexBufferLayout {
|
||||||
|
array_stride: size_of::<DrawVert>() as BufferAddress,
|
||||||
|
step_mode: VertexStepMode::Vertex,
|
||||||
|
attributes: &vertex_attr_array![0 => Float32x2, 1 => Float32x2, 2 => Unorm8x4],
|
||||||
|
}],
|
||||||
|
},
|
||||||
|
primitive: PrimitiveState {
|
||||||
|
topology: PrimitiveTopology::TriangleList,
|
||||||
|
strip_index_format: None,
|
||||||
|
front_face: FrontFace::Cw,
|
||||||
|
cull_mode: None,
|
||||||
|
polygon_mode: PolygonMode::Fill,
|
||||||
|
unclipped_depth: false,
|
||||||
|
conservative: false,
|
||||||
|
},
|
||||||
|
depth_stencil: depth_format.map(|format| wgpu::DepthStencilState {
|
||||||
|
format,
|
||||||
|
depth_write_enabled: false,
|
||||||
|
depth_compare: wgpu::CompareFunction::Always,
|
||||||
|
stencil: wgpu::StencilState::default(),
|
||||||
|
bias: DepthBiasState::default(),
|
||||||
|
}),
|
||||||
|
multisample: MultisampleState { count: sample_count, ..Default::default() },
|
||||||
|
fragment: Some(FragmentState {
|
||||||
|
module: fs,
|
||||||
|
entry_point: &fragment_shader_entry_point,
|
||||||
|
targets: &[ColorTargetState {
|
||||||
|
format: texture_format,
|
||||||
|
blend: Some(BlendState {
|
||||||
|
color: BlendComponent {
|
||||||
|
src_factor: BlendFactor::SrcAlpha,
|
||||||
|
dst_factor: BlendFactor::OneMinusSrcAlpha,
|
||||||
|
operation: BlendOperation::Add,
|
||||||
|
},
|
||||||
|
alpha: BlendComponent {
|
||||||
|
src_factor: BlendFactor::OneMinusDstAlpha,
|
||||||
|
dst_factor: BlendFactor::One,
|
||||||
|
operation: BlendOperation::Add,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
write_mask: ColorWrites::ALL,
|
||||||
|
}],
|
||||||
|
}),
|
||||||
|
multiview: None,
|
||||||
|
});
|
||||||
|
|
||||||
|
let mut renderer = Self {
|
||||||
|
pipeline,
|
||||||
|
uniform_buffer,
|
||||||
|
uniform_bind_group,
|
||||||
|
textures: Textures::new(),
|
||||||
|
texture_layout,
|
||||||
|
vertex_buffers: SmallVec::new(),
|
||||||
|
index_buffers: SmallVec::new(),
|
||||||
|
config: RendererConfig {
|
||||||
|
texture_format,
|
||||||
|
depth_format,
|
||||||
|
sample_count,
|
||||||
|
shader: ShaderType::None,
|
||||||
|
vertex_shader_entry_point,
|
||||||
|
fragment_shader_entry_point,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
// Immediately load the font texture to the GPU.
|
||||||
|
renderer.reload_font_texture(imgui, device, queue);
|
||||||
|
|
||||||
|
renderer
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Render the current imgui frame.
|
||||||
|
pub fn render<'r>(
|
||||||
|
&'r mut self,
|
||||||
|
draw_data: &DrawData,
|
||||||
|
queue: &Queue,
|
||||||
|
device: &Device,
|
||||||
|
rpass: &mut RenderPass<'r>,
|
||||||
|
) -> RendererResult<()> {
|
||||||
|
rpass.push_debug_group("imgui-wgpu");
|
||||||
|
let mut rpass = scopeguard::guard(rpass, |rpass| {
|
||||||
|
rpass.pop_debug_group();
|
||||||
|
});
|
||||||
|
|
||||||
|
let fb_width = draw_data.display_size[0] * draw_data.framebuffer_scale[0];
|
||||||
|
let fb_height = draw_data.display_size[1] * draw_data.framebuffer_scale[1];
|
||||||
|
|
||||||
|
// If the render area is <= 0, exit here and now.
|
||||||
|
if !(fb_width > 0.0 && fb_height > 0.0) {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
|
let width = draw_data.display_size[0];
|
||||||
|
let height = draw_data.display_size[1];
|
||||||
|
|
||||||
|
let offset_x = draw_data.display_pos[0] / width;
|
||||||
|
let offset_y = draw_data.display_pos[1] / height;
|
||||||
|
|
||||||
|
// Create and update the transform matrix for the current frame.
|
||||||
|
// This is required to adapt to vulkan coordinates.
|
||||||
|
// let matrix = [
|
||||||
|
// [2.0 / width, 0.0, 0.0, 0.0],
|
||||||
|
// [0.0, 2.0 / height as f32, 0.0, 0.0],
|
||||||
|
// [0.0, 0.0, -1.0, 0.0],
|
||||||
|
// [-1.0, -1.0, 0.0, 1.0],
|
||||||
|
// ];
|
||||||
|
let matrix = [
|
||||||
|
[2.0 / width, 0.0, 0.0, 0.0],
|
||||||
|
[0.0, 2.0 / -height as f32, 0.0, 0.0],
|
||||||
|
[0.0, 0.0, 1.0, 0.0],
|
||||||
|
[-1.0 - offset_x * 2.0, 1.0 + offset_y * 2.0, 0.0, 1.0],
|
||||||
|
];
|
||||||
|
self.update_uniform_buffer(queue, &matrix);
|
||||||
|
|
||||||
|
rpass.set_pipeline(&self.pipeline);
|
||||||
|
rpass.set_bind_group(0, &self.uniform_bind_group, &[]);
|
||||||
|
|
||||||
|
self.vertex_buffers.clear();
|
||||||
|
self.index_buffers.clear();
|
||||||
|
|
||||||
|
for draw_list in draw_data.draw_lists() {
|
||||||
|
self.vertex_buffers.push(self.upload_vertex_buffer(device, draw_list.vtx_buffer()));
|
||||||
|
self.index_buffers.push(self.upload_index_buffer(device, draw_list.idx_buffer()));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Execute all the imgui render work.
|
||||||
|
for (draw_list_buffers_index, draw_list) in draw_data.draw_lists().enumerate() {
|
||||||
|
self.render_draw_list(
|
||||||
|
rpass.borrow_mut(),
|
||||||
|
draw_list,
|
||||||
|
draw_data.display_pos,
|
||||||
|
draw_data.framebuffer_scale,
|
||||||
|
draw_list_buffers_index,
|
||||||
|
)?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Render a given `DrawList` from imgui onto a wgpu frame.
|
||||||
|
fn render_draw_list<'render>(
|
||||||
|
&'render self,
|
||||||
|
rpass: &mut RenderPass<'render>,
|
||||||
|
draw_list: &DrawList,
|
||||||
|
clip_off: [f32; 2],
|
||||||
|
clip_scale: [f32; 2],
|
||||||
|
draw_list_buffers_index: usize,
|
||||||
|
) -> RendererResult<()> {
|
||||||
|
let mut start = 0;
|
||||||
|
|
||||||
|
let index_buffer = &self.index_buffers[draw_list_buffers_index];
|
||||||
|
let vertex_buffer = &self.vertex_buffers[draw_list_buffers_index];
|
||||||
|
|
||||||
|
// Make sure the current buffers are attached to the render pass.
|
||||||
|
rpass.set_index_buffer(index_buffer.slice(..), IndexFormat::Uint16);
|
||||||
|
rpass.set_vertex_buffer(0, vertex_buffer.slice(..));
|
||||||
|
|
||||||
|
for cmd in draw_list.commands() {
|
||||||
|
if let Elements { count, cmd_params } = cmd {
|
||||||
|
let clip_rect = [
|
||||||
|
(cmd_params.clip_rect[0] - clip_off[0]) * clip_scale[0],
|
||||||
|
(cmd_params.clip_rect[1] - clip_off[1]) * clip_scale[1],
|
||||||
|
(cmd_params.clip_rect[2] - clip_off[0]) * clip_scale[0],
|
||||||
|
(cmd_params.clip_rect[3] - clip_off[1]) * clip_scale[1],
|
||||||
|
];
|
||||||
|
|
||||||
|
// Set the current texture bind group on the renderpass.
|
||||||
|
let texture_id = cmd_params.texture_id;
|
||||||
|
let tex =
|
||||||
|
self.textures.get(texture_id).ok_or(RendererError::BadTexture(texture_id))?;
|
||||||
|
rpass.set_bind_group(1, &tex.bind_group, &[]);
|
||||||
|
|
||||||
|
// Set scissors on the renderpass.
|
||||||
|
let scissors = (
|
||||||
|
clip_rect[0].max(0.0).floor() as u32,
|
||||||
|
clip_rect[1].max(0.0).floor() as u32,
|
||||||
|
(clip_rect[2] - clip_rect[0]).abs().ceil() as u32,
|
||||||
|
(clip_rect[3] - clip_rect[1]).abs().ceil() as u32,
|
||||||
|
);
|
||||||
|
rpass.set_scissor_rect(scissors.0, scissors.1, scissors.2, scissors.3);
|
||||||
|
|
||||||
|
// Draw the current batch of vertices with the renderpass.
|
||||||
|
let end = start + count as u32;
|
||||||
|
rpass.draw_indexed(start..end, 0, 0..1);
|
||||||
|
start = end;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Updates the current uniform buffer containing the transform matrix.
|
||||||
|
fn update_uniform_buffer(&mut self, queue: &Queue, matrix: &[[f32; 4]; 4]) {
|
||||||
|
let data = bytemuck::bytes_of(matrix);
|
||||||
|
|
||||||
|
queue.write_buffer(&self.uniform_buffer, 0, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Upload the vertex buffer to the GPU.
|
||||||
|
fn upload_vertex_buffer(&self, device: &Device, vertices: &[DrawVert]) -> Buffer {
|
||||||
|
// Safety: DrawVertPod is #[repr(transparent)] over DrawVert and DrawVert _should_ be Pod.
|
||||||
|
let vertices = unsafe {
|
||||||
|
std::slice::from_raw_parts(vertices.as_ptr() as *mut DrawVertPod, vertices.len())
|
||||||
|
};
|
||||||
|
|
||||||
|
let data = bytemuck::cast_slice(vertices);
|
||||||
|
device.create_buffer_init(&BufferInitDescriptor {
|
||||||
|
label: Some("imgui-wgpu vertex buffer"),
|
||||||
|
contents: data,
|
||||||
|
usage: BufferUsages::VERTEX,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Upload the index buffer to the GPU.
|
||||||
|
fn upload_index_buffer(&self, device: &Device, indices: &[DrawIdx]) -> Buffer {
|
||||||
|
let data = bytemuck::cast_slice(indices);
|
||||||
|
|
||||||
|
device.create_buffer_init(&BufferInitDescriptor {
|
||||||
|
label: Some("imgui-wgpu index buffer"),
|
||||||
|
contents: data,
|
||||||
|
usage: BufferUsages::INDEX,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Updates the texture on the GPU corresponding to the current imgui font atlas.
|
||||||
|
///
|
||||||
|
/// This has to be called after loading a font.
|
||||||
|
pub fn reload_font_texture(&mut self, imgui: &mut Context, device: &Device, queue: &Queue) {
|
||||||
|
let mut fonts = imgui.fonts();
|
||||||
|
// Remove possible font atlas texture.
|
||||||
|
self.textures.remove(fonts.tex_id);
|
||||||
|
|
||||||
|
// Create font texture and upload it.
|
||||||
|
let handle = fonts.build_rgba32_texture();
|
||||||
|
let font_texture_cnfig = TextureConfig {
|
||||||
|
label: Some("imgui-wgpu font atlas"),
|
||||||
|
size: Extent3d { width: handle.width, height: handle.height, ..Default::default() },
|
||||||
|
format: Some(wgpu::TextureFormat::Rgba8Unorm),
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
|
||||||
|
let font_texture = Texture::new(device, self, font_texture_cnfig);
|
||||||
|
font_texture.write(queue, handle.data, handle.width, handle.height);
|
||||||
|
fonts.tex_id = self.textures.insert(font_texture);
|
||||||
|
// Clear imgui texture data to save memory.
|
||||||
|
fonts.clear_tex_data();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,345 @@
|
||||||
|
#![allow(dead_code)]
|
||||||
|
#![allow(unused_imports)]
|
||||||
|
#![allow(unused_variables)]
|
||||||
|
#![allow(unused_unsafe)]
|
||||||
|
|
||||||
|
use std::{num::NonZeroU8, time::Instant};
|
||||||
|
|
||||||
|
use wgpu::Backend;
|
||||||
|
use winit::{
|
||||||
|
event::{Event, WindowEvent},
|
||||||
|
event_loop::ControlFlow,
|
||||||
|
};
|
||||||
|
|
||||||
|
use crate::{
|
||||||
|
gpu::{create_depth_texture, create_render_texture, initialize_gpu, DeviceHolder},
|
||||||
|
imgui::{initialize_imgui, ImGuiState},
|
||||||
|
shaders::render_into_pass,
|
||||||
|
};
|
||||||
|
|
||||||
|
mod gpu;
|
||||||
|
mod imgui;
|
||||||
|
mod imgui_backend;
|
||||||
|
mod shaders;
|
||||||
|
mod zeus;
|
||||||
|
|
||||||
|
#[cxx::bridge(namespace = "aurora")]
|
||||||
|
mod ffi {
|
||||||
|
unsafe extern "C++" {
|
||||||
|
include!("aurora.hpp");
|
||||||
|
pub(crate) type AppDelegate;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe extern "C++" {
|
||||||
|
include!("lib.hpp");
|
||||||
|
pub(crate) fn App_onAppLaunched(cb: Pin<&mut AppDelegate>);
|
||||||
|
pub(crate) fn App_onAppIdle(cb: Pin<&mut AppDelegate>, dt: f32) -> bool;
|
||||||
|
pub(crate) fn App_onAppDraw(cb: Pin<&mut AppDelegate>);
|
||||||
|
pub(crate) fn App_onAppPostDraw(cb: Pin<&mut AppDelegate>);
|
||||||
|
pub(crate) fn App_onAppExiting(cb: Pin<&mut AppDelegate>);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct Window {
|
||||||
|
pub(crate) inner: Box<WindowContext>,
|
||||||
|
}
|
||||||
|
pub struct WindowSize {
|
||||||
|
pub width: u32,
|
||||||
|
pub height: u32,
|
||||||
|
}
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub enum Backend {
|
||||||
|
Invalid,
|
||||||
|
Vulkan,
|
||||||
|
Metal,
|
||||||
|
D3D12,
|
||||||
|
D3D11,
|
||||||
|
OpenGL,
|
||||||
|
WebGPU,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub enum ElementState {
|
||||||
|
Pressed,
|
||||||
|
Released,
|
||||||
|
}
|
||||||
|
pub enum MouseButton {
|
||||||
|
Left,
|
||||||
|
Right,
|
||||||
|
Middle,
|
||||||
|
Other,
|
||||||
|
}
|
||||||
|
pub enum SpecialKey {
|
||||||
|
None = 0,
|
||||||
|
F1 = 1,
|
||||||
|
F2 = 2,
|
||||||
|
F3 = 3,
|
||||||
|
F4 = 4,
|
||||||
|
F5 = 5,
|
||||||
|
F6 = 6,
|
||||||
|
F7 = 7,
|
||||||
|
F8 = 8,
|
||||||
|
F9 = 9,
|
||||||
|
F10 = 10,
|
||||||
|
F11 = 11,
|
||||||
|
F12 = 12,
|
||||||
|
Esc = 13,
|
||||||
|
Enter = 14,
|
||||||
|
Backspace = 15,
|
||||||
|
Insert = 16,
|
||||||
|
Delete = 17,
|
||||||
|
Home = 18,
|
||||||
|
End = 19,
|
||||||
|
PgUp = 20,
|
||||||
|
PgDown = 21,
|
||||||
|
Left = 22,
|
||||||
|
Right = 23,
|
||||||
|
Up = 24,
|
||||||
|
Down = 25,
|
||||||
|
Tab = 26,
|
||||||
|
}
|
||||||
|
pub struct KeyboardInput {
|
||||||
|
pub scancode: u32,
|
||||||
|
pub state: ElementState,
|
||||||
|
// pub
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "Rust" {
|
||||||
|
type WindowContext;
|
||||||
|
type App;
|
||||||
|
fn app_run(mut delegate: UniquePtr<AppDelegate>);
|
||||||
|
fn get_args() -> Vec<String>;
|
||||||
|
fn get_window_size() -> WindowSize;
|
||||||
|
fn set_window_title(title: &CxxString);
|
||||||
|
fn get_backend() -> Backend;
|
||||||
|
fn get_backend_string() -> &'static str;
|
||||||
|
fn set_fullscreen(v: bool);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct App {
|
||||||
|
window: ffi::Window,
|
||||||
|
gpu: DeviceHolder,
|
||||||
|
imgui: ImGuiState,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct WindowContext {
|
||||||
|
window: winit::window::Window,
|
||||||
|
}
|
||||||
|
|
||||||
|
static mut APP: Option<App> = None;
|
||||||
|
|
||||||
|
fn app_run(mut delegate: cxx::UniquePtr<ffi::AppDelegate>) {
|
||||||
|
if delegate.is_null() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
env_logger::init();
|
||||||
|
log::info!("Running app");
|
||||||
|
let event_loop = winit::event_loop::EventLoop::new();
|
||||||
|
let window = winit::window::WindowBuilder::new().build(&event_loop).unwrap();
|
||||||
|
let gpu = initialize_gpu(&window);
|
||||||
|
let imgui = initialize_imgui(&window, &gpu);
|
||||||
|
shaders::construct_state(gpu.device.clone(), gpu.queue.clone(), &gpu.config);
|
||||||
|
let app = App { window: ffi::Window { inner: Box::new(WindowContext { window }) }, gpu, imgui };
|
||||||
|
unsafe {
|
||||||
|
APP.replace(app);
|
||||||
|
ffi::App_onAppLaunched(delegate.as_mut().unwrap());
|
||||||
|
};
|
||||||
|
event_loop.run(move |event, _, control_flow| {
|
||||||
|
// Have the closure take ownership of the resources.
|
||||||
|
// `event_loop.run` never returns, therefore we must do this to ensure
|
||||||
|
// the resources are properly cleaned up.
|
||||||
|
let _ = &delegate;
|
||||||
|
|
||||||
|
let app = get_app();
|
||||||
|
let imgui = &mut app.imgui;
|
||||||
|
let window_ctx = get_window_context();
|
||||||
|
let gpu = &mut app.gpu;
|
||||||
|
let mut last_frame: Option<Instant> = None;
|
||||||
|
|
||||||
|
*control_flow = ControlFlow::Poll;
|
||||||
|
match event {
|
||||||
|
Event::NewEvents(_) => {}
|
||||||
|
Event::WindowEvent { event: WindowEvent::CloseRequested, .. } => {
|
||||||
|
*control_flow = ControlFlow::Exit;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Event::WindowEvent { event: WindowEvent::Resized(size), .. } => {
|
||||||
|
// Reconfigure the surface with the new size
|
||||||
|
app.gpu.surface_config.width = size.width;
|
||||||
|
app.gpu.surface_config.height = size.height;
|
||||||
|
app.gpu.surface.configure(&app.gpu.device, &app.gpu.surface_config);
|
||||||
|
app.gpu.depth =
|
||||||
|
create_depth_texture(&app.gpu.device, &app.gpu.surface_config, &app.gpu.config);
|
||||||
|
app.gpu.framebuffer = create_render_texture(
|
||||||
|
&app.gpu.device,
|
||||||
|
&app.gpu.surface_config,
|
||||||
|
&app.gpu.config,
|
||||||
|
);
|
||||||
|
// TODO resize callback
|
||||||
|
}
|
||||||
|
Event::WindowEvent { event: WindowEvent::KeyboardInput { .. }, .. } => {}
|
||||||
|
Event::WindowEvent { .. } => {}
|
||||||
|
Event::DeviceEvent { .. } => {}
|
||||||
|
Event::UserEvent(_) => {}
|
||||||
|
Event::Suspended => {}
|
||||||
|
Event::Resumed => {}
|
||||||
|
Event::MainEventsCleared => {
|
||||||
|
log::info!("Requesting redraw");
|
||||||
|
window_ctx.window.request_redraw();
|
||||||
|
}
|
||||||
|
Event::RedrawRequested(_) => {
|
||||||
|
let io = imgui.context.io_mut();
|
||||||
|
let mut dt: f32 = 1.0 / 60.0;
|
||||||
|
if let Some(last_frame) = last_frame {
|
||||||
|
let duration = last_frame.elapsed();
|
||||||
|
dt = duration.as_secs_f32();
|
||||||
|
io.update_delta_time(duration);
|
||||||
|
}
|
||||||
|
last_frame = Some(Instant::now());
|
||||||
|
|
||||||
|
imgui
|
||||||
|
.platform
|
||||||
|
.prepare_frame(io, &window_ctx.window)
|
||||||
|
.expect("Failed to prepare frame");
|
||||||
|
let ui = imgui.context.frame();
|
||||||
|
|
||||||
|
#[allow(unused_unsafe)] // rust bug?
|
||||||
|
if !unsafe { ffi::App_onAppIdle(delegate.as_mut().unwrap(), dt) } {
|
||||||
|
*control_flow = ControlFlow::Exit;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
log::info!("Redrawing");
|
||||||
|
let frame_result = gpu.surface.get_current_texture();
|
||||||
|
if let Err(err) = frame_result {
|
||||||
|
log::warn!("Failed to acquire frame {}", err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let frame = frame_result.unwrap();
|
||||||
|
|
||||||
|
#[allow(unused_unsafe)] // rust bug?
|
||||||
|
unsafe {
|
||||||
|
ffi::App_onAppDraw(delegate.as_mut().unwrap());
|
||||||
|
}
|
||||||
|
|
||||||
|
let fb_view =
|
||||||
|
gpu.framebuffer.texture.create_view(&wgpu::TextureViewDescriptor::default());
|
||||||
|
let view = frame.texture.create_view(&wgpu::TextureViewDescriptor::default());
|
||||||
|
let mut encoder =
|
||||||
|
gpu.device.create_command_encoder(&wgpu::CommandEncoderDescriptor {
|
||||||
|
label: Some("Redraw Encoder"),
|
||||||
|
});
|
||||||
|
{
|
||||||
|
let mut rpass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
|
||||||
|
label: None,
|
||||||
|
color_attachments: &[if gpu.config.msaa_samples > 1 {
|
||||||
|
wgpu::RenderPassColorAttachment {
|
||||||
|
view: &fb_view,
|
||||||
|
resolve_target: Some(&view),
|
||||||
|
ops: wgpu::Operations {
|
||||||
|
load: wgpu::LoadOp::Clear(wgpu::Color::BLACK),
|
||||||
|
store: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
wgpu::RenderPassColorAttachment {
|
||||||
|
view: &view,
|
||||||
|
resolve_target: None,
|
||||||
|
ops: wgpu::Operations {
|
||||||
|
load: wgpu::LoadOp::Clear(wgpu::Color::BLACK),
|
||||||
|
store: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}],
|
||||||
|
depth_stencil_attachment: Some(wgpu::RenderPassDepthStencilAttachment {
|
||||||
|
view: &gpu.depth.view,
|
||||||
|
depth_ops: Some(wgpu::Operations {
|
||||||
|
load: wgpu::LoadOp::Clear(1.0),
|
||||||
|
store: true,
|
||||||
|
}),
|
||||||
|
stencil_ops: None,
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
|
render_into_pass(&mut rpass);
|
||||||
|
|
||||||
|
imgui.platform.prepare_render(&ui, &window_ctx.window);
|
||||||
|
imgui
|
||||||
|
.backend
|
||||||
|
.render(ui.render(), &gpu.queue, &gpu.device, &mut rpass)
|
||||||
|
.expect("Rendering failed");
|
||||||
|
}
|
||||||
|
|
||||||
|
gpu.queue.submit(Some(encoder.finish()));
|
||||||
|
frame.present();
|
||||||
|
|
||||||
|
#[allow(unused_unsafe)] // rust bug?
|
||||||
|
unsafe {
|
||||||
|
ffi::App_onAppPostDraw(delegate.as_mut().unwrap());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Event::RedrawEventsCleared => {}
|
||||||
|
Event::LoopDestroyed => unsafe {
|
||||||
|
ffi::App_onAppExiting(delegate.as_mut().unwrap());
|
||||||
|
APP.take();
|
||||||
|
return;
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
imgui.platform.handle_event(imgui.context.io_mut(), &window_ctx.window, &event);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_app() -> &'static mut App {
|
||||||
|
unsafe {
|
||||||
|
if let Some(ref mut app) = APP {
|
||||||
|
app
|
||||||
|
} else {
|
||||||
|
panic!("Application not initialized");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_window_context() -> &'static mut WindowContext { &mut get_app().window.inner }
|
||||||
|
|
||||||
|
fn get_args() -> Vec<String> { std::env::args().skip(1).collect() }
|
||||||
|
|
||||||
|
fn get_window_size() -> ffi::WindowSize {
|
||||||
|
let size = get_window_context().window.inner_size();
|
||||||
|
ffi::WindowSize { width: size.width, height: size.height }
|
||||||
|
}
|
||||||
|
|
||||||
|
fn set_window_title(title: &cxx::CxxString) {
|
||||||
|
get_window_context().window.set_title(&title.to_string_lossy());
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_backend() -> ffi::Backend {
|
||||||
|
match get_app().gpu.backend {
|
||||||
|
Backend::Vulkan => ffi::Backend::Vulkan,
|
||||||
|
Backend::Metal => ffi::Backend::Metal,
|
||||||
|
Backend::Dx12 => ffi::Backend::D3D12,
|
||||||
|
Backend::Dx11 => ffi::Backend::D3D11,
|
||||||
|
Backend::Gl => ffi::Backend::OpenGL,
|
||||||
|
Backend::BrowserWebGpu => ffi::Backend::WebGPU,
|
||||||
|
Backend::Empty => ffi::Backend::Invalid,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_backend_string() -> &'static str {
|
||||||
|
match get_app().gpu.backend {
|
||||||
|
Backend::Vulkan => "Vulkan",
|
||||||
|
Backend::Metal => "Metal",
|
||||||
|
Backend::Dx12 => "D3D12",
|
||||||
|
Backend::Dx11 => "D3D11",
|
||||||
|
Backend::Gl => "OpenGL ES",
|
||||||
|
Backend::BrowserWebGpu => "WebGPU",
|
||||||
|
Backend::Empty => "Invalid",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn set_fullscreen(v: bool) {
|
||||||
|
get_window_context().window.set_fullscreen(if v {
|
||||||
|
Some(winit::window::Fullscreen::Borderless(None))
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
});
|
||||||
|
}
|
|
@ -0,0 +1,203 @@
|
||||||
|
use std::{hash::Hash, ops::Range};
|
||||||
|
|
||||||
|
use bytemuck_derive::{Pod, Zeroable};
|
||||||
|
use wgpu::{include_wgsl, vertex_attr_array};
|
||||||
|
|
||||||
|
use crate::{
|
||||||
|
gpu::GraphicsConfig,
|
||||||
|
shaders::{
|
||||||
|
bind_pipeline, get_combined_matrix, pipeline_ref, push_draw_command, push_uniform,
|
||||||
|
push_verts, BuiltBuffers, PipelineCreateCommand, PipelineHolder, PipelineRef,
|
||||||
|
ShaderDrawCommand,
|
||||||
|
},
|
||||||
|
zeus::{CAABox, CColor, CMatrix4f, CVector3f},
|
||||||
|
};
|
||||||
|
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
pub(crate) struct DrawData {
|
||||||
|
pipeline: PipelineRef,
|
||||||
|
vert_range: Range<u64>,
|
||||||
|
uniform_range: Range<u64>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Hash)]
|
||||||
|
pub(crate) struct PipelineConfig {
|
||||||
|
z_only: bool,
|
||||||
|
}
|
||||||
|
pub(crate) const INITIAL_PIPELINES: &[PipelineConfig] =
|
||||||
|
&[PipelineConfig { z_only: false }, PipelineConfig { z_only: true }];
|
||||||
|
|
||||||
|
pub(crate) struct State {
|
||||||
|
shader: wgpu::ShaderModule,
|
||||||
|
uniform_layout: wgpu::BindGroupLayout,
|
||||||
|
uniform_bind_group: wgpu::BindGroup,
|
||||||
|
pipeline_layout: wgpu::PipelineLayout,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn construct_state(
|
||||||
|
device: &wgpu::Device,
|
||||||
|
_queue: &wgpu::Queue,
|
||||||
|
buffers: &BuiltBuffers,
|
||||||
|
) -> State {
|
||||||
|
let shader = device.create_shader_module(&include_wgsl!("aabb.wgsl"));
|
||||||
|
let uniform_size = wgpu::BufferSize::new(std::mem::size_of::<Uniform>() as u64);
|
||||||
|
let uniform_layout = device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
|
||||||
|
label: Some("AABB Bind Group Layout"),
|
||||||
|
entries: &[wgpu::BindGroupLayoutEntry {
|
||||||
|
binding: 0,
|
||||||
|
visibility: wgpu::ShaderStages::VERTEX_FRAGMENT,
|
||||||
|
ty: wgpu::BindingType::Buffer {
|
||||||
|
ty: wgpu::BufferBindingType::Uniform,
|
||||||
|
has_dynamic_offset: true,
|
||||||
|
min_binding_size: uniform_size,
|
||||||
|
},
|
||||||
|
count: None,
|
||||||
|
}],
|
||||||
|
});
|
||||||
|
let uniform_bind_group = device.create_bind_group(&wgpu::BindGroupDescriptor {
|
||||||
|
label: Some("AABB Bind Group"),
|
||||||
|
layout: &uniform_layout,
|
||||||
|
entries: &[wgpu::BindGroupEntry {
|
||||||
|
binding: 0,
|
||||||
|
resource: wgpu::BindingResource::Buffer(wgpu::BufferBinding {
|
||||||
|
buffer: &buffers.uniform_buffer,
|
||||||
|
offset: 0, // dynamic
|
||||||
|
size: uniform_size,
|
||||||
|
}),
|
||||||
|
}],
|
||||||
|
});
|
||||||
|
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
|
||||||
|
label: Some("AABB Pipeline Layout"),
|
||||||
|
bind_group_layouts: &[&uniform_layout],
|
||||||
|
push_constant_ranges: &[],
|
||||||
|
});
|
||||||
|
State { shader, uniform_layout, uniform_bind_group, pipeline_layout }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn construct_pipeline(
|
||||||
|
device: &wgpu::Device,
|
||||||
|
graphics: &GraphicsConfig,
|
||||||
|
state: &State,
|
||||||
|
config: &PipelineConfig,
|
||||||
|
) -> PipelineHolder {
|
||||||
|
PipelineHolder {
|
||||||
|
pipeline: device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
|
||||||
|
label: Some("AABB Pipeline"),
|
||||||
|
layout: Some(&state.pipeline_layout),
|
||||||
|
vertex: wgpu::VertexState {
|
||||||
|
module: &state.shader,
|
||||||
|
entry_point: "vs_main",
|
||||||
|
buffers: &[wgpu::VertexBufferLayout {
|
||||||
|
array_stride: std::mem::size_of::<CVector3f>() as u64,
|
||||||
|
step_mode: wgpu::VertexStepMode::Vertex,
|
||||||
|
attributes: &vertex_attr_array![0 => Float32x3],
|
||||||
|
}],
|
||||||
|
},
|
||||||
|
primitive: wgpu::PrimitiveState {
|
||||||
|
topology: wgpu::PrimitiveTopology::TriangleStrip,
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
depth_stencil: Some(wgpu::DepthStencilState {
|
||||||
|
format: graphics.depth_format,
|
||||||
|
depth_write_enabled: true,
|
||||||
|
depth_compare: wgpu::CompareFunction::LessEqual,
|
||||||
|
stencil: Default::default(),
|
||||||
|
bias: Default::default(),
|
||||||
|
}),
|
||||||
|
multisample: wgpu::MultisampleState {
|
||||||
|
count: graphics.msaa_samples,
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
fragment: Some(wgpu::FragmentState {
|
||||||
|
module: &state.shader,
|
||||||
|
entry_point: "fs_main",
|
||||||
|
targets: &[wgpu::ColorTargetState {
|
||||||
|
format: graphics.color_format,
|
||||||
|
blend: Some(wgpu::BlendState {
|
||||||
|
color: wgpu::BlendComponent {
|
||||||
|
src_factor: wgpu::BlendFactor::SrcAlpha,
|
||||||
|
dst_factor: wgpu::BlendFactor::OneMinusSrcAlpha,
|
||||||
|
operation: wgpu::BlendOperation::Add,
|
||||||
|
},
|
||||||
|
alpha: wgpu::BlendComponent {
|
||||||
|
src_factor: wgpu::BlendFactor::SrcAlpha,
|
||||||
|
dst_factor: wgpu::BlendFactor::OneMinusSrcAlpha,
|
||||||
|
operation: wgpu::BlendOperation::Add,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
write_mask: if config.z_only {
|
||||||
|
wgpu::ColorWrites::empty()
|
||||||
|
} else {
|
||||||
|
wgpu::ColorWrites::ALL
|
||||||
|
},
|
||||||
|
}],
|
||||||
|
}),
|
||||||
|
multiview: None,
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Pod, Zeroable, Copy, Clone, Default, Debug)]
|
||||||
|
#[repr(C)]
|
||||||
|
struct Uniform {
|
||||||
|
xf: CMatrix4f,
|
||||||
|
color: CColor,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn queue_aabb(aabb: CAABox, color: CColor, z_only: bool) {
|
||||||
|
let pipeline = pipeline_ref(PipelineCreateCommand::Aabb(PipelineConfig { z_only }));
|
||||||
|
let vert_range = push_verts(&[
|
||||||
|
CVector3f::new(aabb.max.x, aabb.max.y, aabb.min.z),
|
||||||
|
CVector3f::new(aabb.max.x, aabb.min.y, aabb.min.z),
|
||||||
|
CVector3f::new(aabb.max.x, aabb.max.y, aabb.max.z),
|
||||||
|
CVector3f::new(aabb.max.x, aabb.min.y, aabb.max.z),
|
||||||
|
CVector3f::new(aabb.max.x, aabb.min.y, aabb.max.z),
|
||||||
|
CVector3f::new(aabb.min.x, aabb.max.y, aabb.min.z),
|
||||||
|
CVector3f::new(aabb.min.x, aabb.max.y, aabb.min.z),
|
||||||
|
CVector3f::new(aabb.max.x, aabb.max.y, aabb.min.z),
|
||||||
|
CVector3f::new(aabb.min.x, aabb.max.y, aabb.max.z),
|
||||||
|
CVector3f::new(aabb.max.x, aabb.max.y, aabb.max.z),
|
||||||
|
CVector3f::new(aabb.max.x, aabb.max.y, aabb.max.z),
|
||||||
|
CVector3f::new(aabb.min.x, aabb.max.y, aabb.min.z),
|
||||||
|
CVector3f::new(aabb.min.x, aabb.max.y, aabb.min.z),
|
||||||
|
CVector3f::new(aabb.min.x, aabb.min.y, aabb.min.z),
|
||||||
|
CVector3f::new(aabb.min.x, aabb.max.y, aabb.max.z),
|
||||||
|
CVector3f::new(aabb.min.x, aabb.min.y, aabb.max.z),
|
||||||
|
CVector3f::new(aabb.min.x, aabb.min.y, aabb.max.z),
|
||||||
|
CVector3f::new(aabb.min.x, aabb.min.y, aabb.min.z),
|
||||||
|
CVector3f::new(aabb.min.x, aabb.min.y, aabb.min.z),
|
||||||
|
CVector3f::new(aabb.max.x, aabb.min.y, aabb.min.z),
|
||||||
|
CVector3f::new(aabb.min.x, aabb.min.y, aabb.max.z),
|
||||||
|
CVector3f::new(aabb.max.x, aabb.min.y, aabb.max.z),
|
||||||
|
CVector3f::new(aabb.max.x, aabb.min.y, aabb.max.z),
|
||||||
|
CVector3f::new(aabb.min.x, aabb.min.y, aabb.max.z),
|
||||||
|
CVector3f::new(aabb.min.x, aabb.min.y, aabb.max.z),
|
||||||
|
CVector3f::new(aabb.max.x, aabb.min.y, aabb.max.z),
|
||||||
|
CVector3f::new(aabb.min.x, aabb.max.y, aabb.max.z),
|
||||||
|
CVector3f::new(aabb.max.x, aabb.max.y, aabb.max.z),
|
||||||
|
CVector3f::new(aabb.max.x, aabb.max.y, aabb.max.z),
|
||||||
|
CVector3f::new(aabb.min.x, aabb.min.y, aabb.min.z),
|
||||||
|
CVector3f::new(aabb.min.x, aabb.min.y, aabb.min.z),
|
||||||
|
CVector3f::new(aabb.max.x, aabb.min.y, aabb.min.z),
|
||||||
|
CVector3f::new(aabb.min.x, aabb.max.y, aabb.min.z),
|
||||||
|
CVector3f::new(aabb.max.x, aabb.max.y, aabb.min.z),
|
||||||
|
]);
|
||||||
|
let uniform_range = push_uniform(&Uniform { xf: get_combined_matrix(), color });
|
||||||
|
push_draw_command(ShaderDrawCommand::Aabb(DrawData { pipeline, vert_range, uniform_range }));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn draw_aabb<'a>(
|
||||||
|
data: &DrawData,
|
||||||
|
state: &'a State,
|
||||||
|
pass: &mut wgpu::RenderPass<'a>,
|
||||||
|
buffers: &'a BuiltBuffers,
|
||||||
|
) {
|
||||||
|
if !bind_pipeline(data.pipeline, pass) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
pass.set_bind_group(0, &state.uniform_bind_group, &[
|
||||||
|
data.uniform_range.start as wgpu::DynamicOffset
|
||||||
|
]);
|
||||||
|
pass.set_vertex_buffer(0, buffers.vertex_buffer.slice(data.vert_range.clone()));
|
||||||
|
pass.draw(0..34, 0..1);
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
struct Uniform {
|
||||||
|
xf: mat4x4<f32>;
|
||||||
|
color: vec4<f32>;
|
||||||
|
};
|
||||||
|
[[group(0), binding(0)]]
|
||||||
|
var<uniform> ubuf: Uniform;
|
||||||
|
|
||||||
|
[[stage(vertex)]]
|
||||||
|
fn vs_main([[location(0)]] in_pos: vec3<f32>) -> [[builtin(position)]] vec4<f32> {
|
||||||
|
return ubuf.xf * vec4<f32>(in_pos, 1.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
[[stage(fragment)]]
|
||||||
|
fn fs_main() -> [[location(0)]] vec4<f32> {
|
||||||
|
return ubuf.color;
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
use crate::zeus::CColor;
|
||||||
|
|
||||||
|
pub(crate) fn queue_fog_volume_filter(color: CColor, two_way: bool) {}
|
|
@ -0,0 +1,5 @@
|
||||||
|
use cxx::CxxVector;
|
||||||
|
|
||||||
|
use crate::zeus::CVector4f;
|
||||||
|
|
||||||
|
pub(crate) fn queue_fog_volume_plane(verts: &CxxVector<CVector4f>, pass: u8) {}
|
|
@ -0,0 +1,574 @@
|
||||||
|
use std::{
|
||||||
|
collections::{HashMap, VecDeque},
|
||||||
|
hash::{Hash, Hasher},
|
||||||
|
num::NonZeroU8,
|
||||||
|
ops::Range,
|
||||||
|
sync::Arc,
|
||||||
|
};
|
||||||
|
|
||||||
|
use aabb::queue_aabb;
|
||||||
|
use bytemuck::Pod;
|
||||||
|
use bytemuck_derive::{Pod, Zeroable};
|
||||||
|
use cxx::{type_id, ExternType};
|
||||||
|
use fog_volume_filter::queue_fog_volume_filter;
|
||||||
|
use fog_volume_plane::queue_fog_volume_plane;
|
||||||
|
use model::{add_material_set, add_model};
|
||||||
|
use texture::{create_render_texture, create_static_texture_2d, drop_texture};
|
||||||
|
use twox_hash::Xxh3Hash64;
|
||||||
|
use wgpu::RenderPipeline;
|
||||||
|
|
||||||
|
use crate::{
|
||||||
|
gpu::GraphicsConfig,
|
||||||
|
zeus::{CColor, CMatrix4f, CRectangle, CVector2f, CVector3f, IDENTITY_MATRIX4F},
|
||||||
|
};
|
||||||
|
|
||||||
|
mod aabb;
|
||||||
|
mod fog_volume_filter;
|
||||||
|
mod fog_volume_plane;
|
||||||
|
mod model;
|
||||||
|
mod texture;
|
||||||
|
|
||||||
|
#[cxx::bridge]
|
||||||
|
mod ffi {
|
||||||
|
unsafe extern "C++" {
|
||||||
|
include!("zeus/CVector2f.hpp");
|
||||||
|
include!("zeus/CVector3f.hpp");
|
||||||
|
include!("zeus/CVector4f.hpp");
|
||||||
|
include!("zeus/CMatrix4f.hpp");
|
||||||
|
include!("zeus/CColor.hpp");
|
||||||
|
include!("zeus/CRectangle.hpp");
|
||||||
|
include!("zeus/CAABox.hpp");
|
||||||
|
#[namespace = "zeus"]
|
||||||
|
type CVector2f = crate::zeus::CVector2f;
|
||||||
|
#[namespace = "zeus"]
|
||||||
|
type CVector3f = crate::zeus::CVector3f;
|
||||||
|
#[namespace = "zeus"]
|
||||||
|
type CVector4f = crate::zeus::CVector4f;
|
||||||
|
#[namespace = "zeus"]
|
||||||
|
type CMatrix4f = crate::zeus::CMatrix4f;
|
||||||
|
#[namespace = "zeus"]
|
||||||
|
type CColor = crate::zeus::CColor;
|
||||||
|
#[namespace = "zeus"]
|
||||||
|
type CRectangle = crate::zeus::CRectangle;
|
||||||
|
#[namespace = "zeus"]
|
||||||
|
type CAABox = crate::zeus::CAABox;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[namespace = "aurora::shaders"]
|
||||||
|
#[derive(Debug, Copy, Clone)]
|
||||||
|
pub(crate) enum CameraFilterType {
|
||||||
|
Passthru,
|
||||||
|
Multiply,
|
||||||
|
Invert,
|
||||||
|
Add,
|
||||||
|
Subtract,
|
||||||
|
Blend,
|
||||||
|
Widescreen,
|
||||||
|
SceneAdd,
|
||||||
|
NoColor,
|
||||||
|
InvDstMultiply,
|
||||||
|
}
|
||||||
|
#[namespace = "aurora::shaders"]
|
||||||
|
#[derive(Debug, Copy, Clone)]
|
||||||
|
pub(crate) enum ZTest {
|
||||||
|
None,
|
||||||
|
LEqual,
|
||||||
|
GEqual,
|
||||||
|
GEqualZWrite,
|
||||||
|
}
|
||||||
|
#[namespace = "aurora::shaders"]
|
||||||
|
#[derive(Debug, Copy, Clone)]
|
||||||
|
pub(crate) enum TextureFormat {
|
||||||
|
RGBA8,
|
||||||
|
R8,
|
||||||
|
R32Float,
|
||||||
|
DXT1,
|
||||||
|
DXT3,
|
||||||
|
DXT5,
|
||||||
|
BPTC,
|
||||||
|
}
|
||||||
|
#[namespace = "aurora::shaders"]
|
||||||
|
#[derive(Debug, Copy, Clone)]
|
||||||
|
pub(crate) enum TextureClampMode {
|
||||||
|
Repeat,
|
||||||
|
ClampToEdge,
|
||||||
|
ClampToWhite,
|
||||||
|
ClampToBlack,
|
||||||
|
}
|
||||||
|
#[namespace = "aurora::shaders"]
|
||||||
|
#[derive(Debug, Copy, Clone)]
|
||||||
|
pub(crate) struct TextureRef {
|
||||||
|
pub(crate) id: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[namespace = "aurora::shaders"]
|
||||||
|
#[derive(Debug, Copy, Clone)]
|
||||||
|
#[repr(u32)]
|
||||||
|
pub(crate) enum FogMode {
|
||||||
|
None = 0x00,
|
||||||
|
|
||||||
|
PerspLin = 0x02,
|
||||||
|
PerspExp = 0x04,
|
||||||
|
PerspExp2 = 0x05,
|
||||||
|
PerspRevExp = 0x06,
|
||||||
|
PerspRevExp2 = 0x07,
|
||||||
|
|
||||||
|
OrthoLin = 0x0A,
|
||||||
|
OrthoExp = 0x0C,
|
||||||
|
OrthoExp2 = 0x0D,
|
||||||
|
OrthoRevExp = 0x0E,
|
||||||
|
OrthoRevExp2 = 0x0F,
|
||||||
|
}
|
||||||
|
#[namespace = "aurora::shaders"]
|
||||||
|
#[derive(Debug, Copy, Clone)]
|
||||||
|
pub(crate) struct FogState {
|
||||||
|
#[cxx_name = "m_color"]
|
||||||
|
pub(crate) color: CColor,
|
||||||
|
#[cxx_name = "m_A"]
|
||||||
|
pub(crate) a: f32,
|
||||||
|
#[cxx_name = "m_B"]
|
||||||
|
pub(crate) b: f32,
|
||||||
|
#[cxx_name = "m_C"]
|
||||||
|
pub(crate) c: f32,
|
||||||
|
#[cxx_name = "m_mode"]
|
||||||
|
pub(crate) mode: FogMode,
|
||||||
|
}
|
||||||
|
#[namespace = "aurora::shaders"]
|
||||||
|
#[derive(Debug, Copy, Clone)]
|
||||||
|
pub(crate) struct ClipRect {
|
||||||
|
x: i32,
|
||||||
|
y: i32,
|
||||||
|
width: i32,
|
||||||
|
height: i32,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[namespace = "aurora::shaders"]
|
||||||
|
#[derive(Debug, Copy, Clone)]
|
||||||
|
pub(crate) struct MaterialPassInfo {
|
||||||
|
tex_idx: u32,
|
||||||
|
constant_color: CColor,
|
||||||
|
has_constant_color: bool, // would love to use Option...
|
||||||
|
uv_source: u8,
|
||||||
|
uv_anim_type: u8,
|
||||||
|
uv_anim_params: [f32; 9],
|
||||||
|
normalize: bool, // TODO might be static based on uv type?
|
||||||
|
sample_alpha: bool,
|
||||||
|
}
|
||||||
|
#[namespace = "aurora::shaders"]
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
pub(crate) struct MaterialInfo {
|
||||||
|
pass_info: [MaterialPassInfo; 8],
|
||||||
|
texture_ids: Vec<TextureRef>,
|
||||||
|
shader_type: u8,
|
||||||
|
blend_mode: u8,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[namespace = "aurora::shaders"]
|
||||||
|
extern "Rust" {
|
||||||
|
fn update_model_view(mv: CMatrix4f, mv_inv: CMatrix4f);
|
||||||
|
fn update_projection(proj: CMatrix4f);
|
||||||
|
fn update_fog_state(state: FogState);
|
||||||
|
fn set_viewport(rect: CRectangle, znear: f32, zfar: f32);
|
||||||
|
fn set_scissor(x: u32, y: u32, w: u32, h: u32);
|
||||||
|
|
||||||
|
fn resolve_color(rect: ClipRect, bind: u32, clear_depth: bool);
|
||||||
|
fn resolve_depth(rect: ClipRect, bind: u32);
|
||||||
|
|
||||||
|
fn add_material_set(materials: Vec<MaterialInfo>) -> u32;
|
||||||
|
fn add_model(verts: &[u8], indices: &[u8]) -> u32;
|
||||||
|
|
||||||
|
fn queue_aabb(aabb: CAABox, color: CColor, z_only: bool);
|
||||||
|
fn queue_fog_volume_plane(verts: &CxxVector<CVector4f>, pass: u8);
|
||||||
|
fn queue_fog_volume_filter(color: CColor, two_way: bool);
|
||||||
|
|
||||||
|
fn create_static_texture_2d(
|
||||||
|
width: u32,
|
||||||
|
height: u32,
|
||||||
|
mips: u32,
|
||||||
|
format: TextureFormat,
|
||||||
|
data: &[u8],
|
||||||
|
label: &str,
|
||||||
|
) -> TextureRef;
|
||||||
|
fn create_render_texture(
|
||||||
|
width: u32,
|
||||||
|
height: u32,
|
||||||
|
// clamp_mode: TextureClampMode,
|
||||||
|
color_bind_count: u32,
|
||||||
|
depth_bind_count: u32,
|
||||||
|
label: &str,
|
||||||
|
) -> TextureRef;
|
||||||
|
fn drop_texture(handle: TextureRef);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe impl bytemuck::Zeroable for ffi::FogMode {}
|
||||||
|
unsafe impl bytemuck::Pod for ffi::FogMode {}
|
||||||
|
unsafe impl bytemuck::Zeroable for ffi::FogState {}
|
||||||
|
unsafe impl bytemuck::Pod for ffi::FogState {}
|
||||||
|
impl Default for ffi::FogState {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self { color: Default::default(), a: 0.0, b: 0.5, c: 0.0, mode: ffi::FogMode::None }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Copy, Clone)]
|
||||||
|
enum ColoredStripMode {
|
||||||
|
Alpha,
|
||||||
|
Additive,
|
||||||
|
FullAdditive,
|
||||||
|
Subtractive,
|
||||||
|
}
|
||||||
|
#[derive(Debug, Copy, Clone)]
|
||||||
|
struct ColoredStripVert {
|
||||||
|
position: CVector3f,
|
||||||
|
color: CColor,
|
||||||
|
uv: CVector2f,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
enum Command {
|
||||||
|
SetViewport(CRectangle, f32, f32),
|
||||||
|
SetScissor(u32, u32, u32, u32),
|
||||||
|
Draw(ShaderDrawCommand),
|
||||||
|
}
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
enum ShaderDrawCommand {
|
||||||
|
Aabb(aabb::DrawData),
|
||||||
|
CameraBlurFilter {
|
||||||
|
amount: f32,
|
||||||
|
clear_depth: bool,
|
||||||
|
},
|
||||||
|
ColoredQuadFilter {
|
||||||
|
filter_type: ffi::CameraFilterType,
|
||||||
|
color: CColor,
|
||||||
|
rect: CRectangle,
|
||||||
|
},
|
||||||
|
ColoredStripFilter {
|
||||||
|
mode: ColoredStripMode,
|
||||||
|
verts: Vec<ColoredStripVert>,
|
||||||
|
color: CColor,
|
||||||
|
},
|
||||||
|
Decal {/* TODO */},
|
||||||
|
ElementGen {/* TODO */},
|
||||||
|
EnergyBar {/* TODO */},
|
||||||
|
EnvFx {/* TODO */},
|
||||||
|
FluidPlane {/* TODO */},
|
||||||
|
FogVolumeFilter {
|
||||||
|
two_way: bool,
|
||||||
|
color: CColor,
|
||||||
|
},
|
||||||
|
FogVolumePlane {
|
||||||
|
pass: u8,
|
||||||
|
verts: Vec<CVector3f>,
|
||||||
|
},
|
||||||
|
LineRenderer {/* TODO */},
|
||||||
|
MapSurface {/* TODO */},
|
||||||
|
Model {
|
||||||
|
pipeline_id: u32,
|
||||||
|
material_id: u32,
|
||||||
|
ambient_color: CColor,
|
||||||
|
lights: u32,
|
||||||
|
post_type: u32,
|
||||||
|
game_blend_mode: u32,
|
||||||
|
model_flags: u32,
|
||||||
|
},
|
||||||
|
MoviePlayer {/* TODO */},
|
||||||
|
NES {/* TODO */},
|
||||||
|
ParticleSwoosh {/* TODO */},
|
||||||
|
PhazonSuitFilter {/* TODO */},
|
||||||
|
RadarPaint {/* TODO */},
|
||||||
|
RandomStaticFilter {/* TODO */},
|
||||||
|
ScanLinesFilter {/* TODO */},
|
||||||
|
TextSupport {/* TODO */},
|
||||||
|
TexturedQuad {
|
||||||
|
filter_type: ffi::CameraFilterType,
|
||||||
|
z_test: ffi::ZTest,
|
||||||
|
tex: u32, /* TODO */
|
||||||
|
/* draw, cropped, verts, filter? */
|
||||||
|
},
|
||||||
|
ThermalCold,
|
||||||
|
ThermalHot,
|
||||||
|
WorldShadow {
|
||||||
|
width: u32,
|
||||||
|
height: u32,
|
||||||
|
extent: f32,
|
||||||
|
},
|
||||||
|
XRayBlur {
|
||||||
|
palette_tex: u32, /* TODO */
|
||||||
|
amount: f32,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
struct RenderState {
|
||||||
|
device: Arc<wgpu::Device>,
|
||||||
|
queue: Arc<wgpu::Queue>,
|
||||||
|
graphics_config: GraphicsConfig,
|
||||||
|
pipelines: HashMap<u64, PipelineHolder>,
|
||||||
|
current_pipeline: u64,
|
||||||
|
uniform_alignment: usize,
|
||||||
|
storage_alignment: usize,
|
||||||
|
buffers: BuiltBuffers,
|
||||||
|
commands: VecDeque<Command>,
|
||||||
|
// Shader states
|
||||||
|
aabb: aabb::State,
|
||||||
|
}
|
||||||
|
pub(crate) fn construct_state(
|
||||||
|
device: Arc<wgpu::Device>,
|
||||||
|
queue: Arc<wgpu::Queue>,
|
||||||
|
graphics_config: &GraphicsConfig,
|
||||||
|
) {
|
||||||
|
let limits = device.limits();
|
||||||
|
let mut buffers = BuiltBuffers {
|
||||||
|
uniform_buffer: device.create_buffer(&wgpu::BufferDescriptor {
|
||||||
|
label: Some("Shared Uniform Buffer"),
|
||||||
|
size: 134_217_728, // 128mb
|
||||||
|
usage: wgpu::BufferUsages::UNIFORM | wgpu::BufferUsages::COPY_DST,
|
||||||
|
mapped_at_creation: false,
|
||||||
|
}),
|
||||||
|
vertex_buffer: device.create_buffer(&wgpu::BufferDescriptor {
|
||||||
|
label: Some("Shared Vertex Buffer"),
|
||||||
|
size: 16_777_216, // 16mb
|
||||||
|
usage: wgpu::BufferUsages::VERTEX | wgpu::BufferUsages::COPY_DST,
|
||||||
|
mapped_at_creation: false,
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
let aabb = aabb::construct_state(&device, &queue, &buffers);
|
||||||
|
let mut state = RenderState {
|
||||||
|
device: device.clone(),
|
||||||
|
queue: queue.clone(),
|
||||||
|
graphics_config: graphics_config.clone(),
|
||||||
|
pipelines: Default::default(),
|
||||||
|
current_pipeline: u64::MAX,
|
||||||
|
uniform_alignment: limits.min_uniform_buffer_offset_alignment as usize,
|
||||||
|
storage_alignment: limits.min_storage_buffer_offset_alignment as usize,
|
||||||
|
buffers,
|
||||||
|
commands: Default::default(),
|
||||||
|
aabb,
|
||||||
|
};
|
||||||
|
for config in aabb::INITIAL_PIPELINES {
|
||||||
|
let hash = hash_with_seed(config, 0xAABB);
|
||||||
|
let pipeline = aabb::construct_pipeline(&device, graphics_config, &state.aabb, config);
|
||||||
|
state.pipelines.insert(hash, pipeline);
|
||||||
|
}
|
||||||
|
unsafe {
|
||||||
|
STATE = Some(state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
static mut STATE: Option<RenderState> = None;
|
||||||
|
|
||||||
|
#[derive(Default, Pod, Zeroable, Copy, Clone)]
|
||||||
|
#[repr(C)]
|
||||||
|
struct GlobalUniform {
|
||||||
|
mv: CMatrix4f,
|
||||||
|
mv_inv: CMatrix4f,
|
||||||
|
proj: CMatrix4f,
|
||||||
|
ambient: CColor, // TODO can this be combined with model?
|
||||||
|
lightmap_mul: CColor,
|
||||||
|
fog: ffi::FogState,
|
||||||
|
}
|
||||||
|
#[derive(Default)]
|
||||||
|
struct GlobalBuffers {
|
||||||
|
uniforms: Vec<u8>,
|
||||||
|
verts: Vec<u8>,
|
||||||
|
|
||||||
|
global_current: GlobalUniform,
|
||||||
|
global_dirty: bool,
|
||||||
|
last_global: Option<Range<u64>>,
|
||||||
|
}
|
||||||
|
static mut GLOBAL_BUFFERS: GlobalBuffers = GlobalBuffers {
|
||||||
|
uniforms: vec![],
|
||||||
|
verts: vec![],
|
||||||
|
global_current: GlobalUniform {
|
||||||
|
mv: IDENTITY_MATRIX4F,
|
||||||
|
mv_inv: IDENTITY_MATRIX4F,
|
||||||
|
proj: IDENTITY_MATRIX4F,
|
||||||
|
ambient: CColor::new(0.0, 0.0, 0.0, 1.0),
|
||||||
|
lightmap_mul: CColor::new(0.0, 0.0, 0.0, 1.0),
|
||||||
|
fog: ffi::FogState {
|
||||||
|
color: CColor::new(0.0, 0.0, 0.0, 0.0),
|
||||||
|
a: 0.0,
|
||||||
|
b: 0.5,
|
||||||
|
c: 0.0,
|
||||||
|
mode: ffi::FogMode::None,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
global_dirty: false,
|
||||||
|
last_global: None,
|
||||||
|
};
|
||||||
|
|
||||||
|
pub(crate) struct PipelineHolder {
|
||||||
|
pipeline: wgpu::RenderPipeline,
|
||||||
|
}
|
||||||
|
pub(crate) struct BuiltBuffers {
|
||||||
|
uniform_buffer: wgpu::Buffer,
|
||||||
|
vertex_buffer: wgpu::Buffer,
|
||||||
|
}
|
||||||
|
|
||||||
|
const EMPTY_SLICE: &[u8] = &[0u8; 256];
|
||||||
|
|
||||||
|
fn push_value<T: Pod>(target: &mut Vec<u8>, buf: &T, alignment: usize) -> Range<u64> {
|
||||||
|
let size_of = std::mem::size_of::<T>();
|
||||||
|
let padding = if alignment == 0 { 0 } else { alignment - size_of % alignment };
|
||||||
|
let begin = target.len() as u64;
|
||||||
|
target.extend_from_slice(bytemuck::bytes_of(buf));
|
||||||
|
if padding > 0 {
|
||||||
|
target.extend_from_slice(&EMPTY_SLICE[..padding]);
|
||||||
|
}
|
||||||
|
begin..begin + size_of as u64
|
||||||
|
}
|
||||||
|
fn push_slice<T: Pod>(target: &mut Vec<u8>, buf: &[T], alignment: usize) -> Range<u64> {
|
||||||
|
let size_of = std::mem::size_of::<T>();
|
||||||
|
let padding = if alignment == 0 { 0 } else { alignment - size_of % alignment };
|
||||||
|
let begin = target.len() as u64;
|
||||||
|
target.extend_from_slice(bytemuck::cast_slice(buf));
|
||||||
|
if padding > 0 {
|
||||||
|
target.extend_from_slice(&EMPTY_SLICE[..padding]);
|
||||||
|
}
|
||||||
|
begin..begin + size_of as u64 * buf.len() as u64
|
||||||
|
}
|
||||||
|
fn push_verts<T: Pod>(buf: &[T]) -> Range<u64> {
|
||||||
|
let global_buffers = unsafe { &mut GLOBAL_BUFFERS };
|
||||||
|
push_slice(&mut global_buffers.verts, buf, 0 /* TODO? */)
|
||||||
|
}
|
||||||
|
fn push_uniform<T: Pod>(buf: &T) -> Range<u64> {
|
||||||
|
let global_buffers = unsafe { &mut GLOBAL_BUFFERS };
|
||||||
|
push_value(&mut global_buffers.uniforms, buf, unsafe {
|
||||||
|
STATE.as_ref().unwrap().uniform_alignment
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Copy, Clone)]
|
||||||
|
struct PipelineRef {
|
||||||
|
id: u64,
|
||||||
|
}
|
||||||
|
|
||||||
|
enum PipelineCreateCommand {
|
||||||
|
Aabb(aabb::PipelineConfig),
|
||||||
|
}
|
||||||
|
#[inline(always)]
|
||||||
|
fn hash_with_seed<T: Hash>(value: &T, seed: u64) -> u64 {
|
||||||
|
let mut state = Xxh3Hash64::with_seed(seed);
|
||||||
|
value.hash(&mut state);
|
||||||
|
state.finish()
|
||||||
|
}
|
||||||
|
fn pipeline_ref(cmd: PipelineCreateCommand) -> PipelineRef {
|
||||||
|
let state = unsafe { STATE.as_mut().unwrap() };
|
||||||
|
let id = match cmd {
|
||||||
|
PipelineCreateCommand::Aabb(ref config) => hash_with_seed(config, 0xAABB),
|
||||||
|
};
|
||||||
|
// TODO queue for creation if not found
|
||||||
|
if !state.pipelines.contains_key(&id) {
|
||||||
|
let pipeline = match cmd {
|
||||||
|
PipelineCreateCommand::Aabb(ref config) => aabb::construct_pipeline(
|
||||||
|
state.device.as_ref(),
|
||||||
|
&state.graphics_config,
|
||||||
|
&state.aabb,
|
||||||
|
config,
|
||||||
|
),
|
||||||
|
};
|
||||||
|
state.pipelines.insert(id, pipeline);
|
||||||
|
}
|
||||||
|
PipelineRef { id }
|
||||||
|
}
|
||||||
|
|
||||||
|
fn bind_pipeline(pipeline_ref: PipelineRef, pass: &mut wgpu::RenderPass) -> bool {
|
||||||
|
let state = unsafe { STATE.as_ref().unwrap() };
|
||||||
|
if pipeline_ref.id == state.current_pipeline {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if let Some(PipelineHolder { pipeline }) = state.pipelines.get(&pipeline_ref.id) {
|
||||||
|
pass.set_pipeline(pipeline);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn render_into_pass(pass: &mut wgpu::RenderPass) {
|
||||||
|
let state = unsafe { STATE.as_mut().unwrap() };
|
||||||
|
{
|
||||||
|
let global_buffers = unsafe { &mut GLOBAL_BUFFERS };
|
||||||
|
state.queue.write_buffer(&state.buffers.vertex_buffer, 0, &global_buffers.verts);
|
||||||
|
state.queue.write_buffer(&state.buffers.uniform_buffer, 0, &global_buffers.uniforms);
|
||||||
|
global_buffers.verts.clear();
|
||||||
|
global_buffers.uniforms.clear();
|
||||||
|
global_buffers.global_dirty = true;
|
||||||
|
}
|
||||||
|
for cmd in &state.commands {
|
||||||
|
match cmd {
|
||||||
|
Command::SetViewport(rect, znear, zfar) => {
|
||||||
|
pass.set_viewport(
|
||||||
|
rect.position.x,
|
||||||
|
rect.position.y,
|
||||||
|
rect.size.x,
|
||||||
|
rect.size.y,
|
||||||
|
*znear,
|
||||||
|
*zfar,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
Command::SetScissor(x, y, w, h) => {
|
||||||
|
pass.set_scissor_rect(*x, *y, *w, *h);
|
||||||
|
}
|
||||||
|
Command::Draw(cmd) => match cmd {
|
||||||
|
ShaderDrawCommand::Aabb(data) => {
|
||||||
|
aabb::draw_aabb(data, &state.aabb, pass, &state.buffers);
|
||||||
|
}
|
||||||
|
_ => todo!(),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
state.commands.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
fn update_model_view(mv: CMatrix4f, mv_inv: CMatrix4f) {
|
||||||
|
let global_buffers = unsafe { &mut GLOBAL_BUFFERS };
|
||||||
|
global_buffers.global_current.mv = mv;
|
||||||
|
global_buffers.global_current.mv_inv = mv_inv;
|
||||||
|
global_buffers.global_dirty = true;
|
||||||
|
}
|
||||||
|
fn update_projection(proj: CMatrix4f) {
|
||||||
|
let global_buffers = unsafe { &mut GLOBAL_BUFFERS };
|
||||||
|
global_buffers.global_current.proj = proj;
|
||||||
|
global_buffers.global_dirty = true;
|
||||||
|
}
|
||||||
|
fn update_fog_state(state: ffi::FogState) {
|
||||||
|
let global_buffers = unsafe { &mut GLOBAL_BUFFERS };
|
||||||
|
global_buffers.global_current.fog = state;
|
||||||
|
global_buffers.global_dirty = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_combined_matrix() -> CMatrix4f {
|
||||||
|
let global_buffers = unsafe { &GLOBAL_BUFFERS };
|
||||||
|
CMatrix4f::from(
|
||||||
|
cgmath::Matrix4::from(global_buffers.global_current.mv)
|
||||||
|
* cgmath::Matrix4::from(global_buffers.global_current.proj),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn finalize_global_uniform() -> Range<u64> {
|
||||||
|
let global_buffers = unsafe { &mut GLOBAL_BUFFERS };
|
||||||
|
if global_buffers.global_dirty || global_buffers.last_global.is_none() {
|
||||||
|
global_buffers.last_global = Some(push_uniform(&global_buffers.global_current));
|
||||||
|
global_buffers.global_dirty = false;
|
||||||
|
}
|
||||||
|
global_buffers.last_global.as_ref().unwrap().clone()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn push_draw_command(cmd: ShaderDrawCommand) {
|
||||||
|
let state = unsafe { STATE.as_mut().unwrap() };
|
||||||
|
state.commands.push_back(Command::Draw(cmd));
|
||||||
|
}
|
||||||
|
fn set_viewport(rect: CRectangle, znear: f32, zfar: f32) {
|
||||||
|
let state = unsafe { STATE.as_mut().unwrap() };
|
||||||
|
state.commands.push_back(Command::SetViewport(rect, znear, zfar));
|
||||||
|
}
|
||||||
|
fn set_scissor(x: u32, y: u32, w: u32, h: u32) {
|
||||||
|
let state = unsafe { STATE.as_mut().unwrap() };
|
||||||
|
state.commands.push_back(Command::SetScissor(x, y, w, h));
|
||||||
|
}
|
||||||
|
|
||||||
|
fn resolve_color(rect: ffi::ClipRect, bind: u32, clear_depth: bool) {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
fn resolve_depth(rect: ffi::ClipRect, bind: u32) {
|
||||||
|
// TODO
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
use std::hash::Hash;
|
||||||
|
|
||||||
|
use crate::shaders::ffi::MaterialInfo;
|
||||||
|
|
||||||
|
struct MaterialShaderData {
|
||||||
|
shader_type: u32, // 5 values (incl. Invalid)
|
||||||
|
world_shadow: u32, // bool
|
||||||
|
alpha_discard: u32, // bool
|
||||||
|
samus_reflection: u32, // bool
|
||||||
|
}
|
||||||
|
struct MaterialPassData {
|
||||||
|
constant_color: [f32; 4],
|
||||||
|
has_constant_color: u32, // bool
|
||||||
|
uv_source: i32, // 8 values
|
||||||
|
normalize: u32, // bool
|
||||||
|
sample_alpha: u32, // bool
|
||||||
|
}
|
||||||
|
|
||||||
|
struct ModelRenderData {
|
||||||
|
// position: [f32; 3], // for UV anims
|
||||||
|
ambient_color: [f32; 4],
|
||||||
|
lights: [f32; 8], // TODO
|
||||||
|
post_type: u32,
|
||||||
|
game_blend_mode: u32,
|
||||||
|
// model_flags: u32, TODO only needed for render
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Hash)]
|
||||||
|
struct ModelPipelineConfig {
|
||||||
|
material_blend_mode: u32,
|
||||||
|
material_depth_write: bool,
|
||||||
|
render_blend_mode: u32,
|
||||||
|
render_model_flags: u32,
|
||||||
|
render_cull_mode: u32,
|
||||||
|
render_dst_alpha: bool,
|
||||||
|
render_color_update: bool,
|
||||||
|
render_alpha_update: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn add_material_set(materials: Vec<MaterialInfo>) -> u32 { return u32::MAX; }
|
||||||
|
pub(crate) fn add_model(verts: &[u8], indices: &[u8]) -> u32 { return u32::MAX; }
|
|
@ -0,0 +1,129 @@
|
||||||
|
use std::ptr::null;
|
||||||
|
|
||||||
|
use cxx::SharedPtr;
|
||||||
|
use wgpu::util::DeviceExt;
|
||||||
|
|
||||||
|
use crate::{
|
||||||
|
get_app,
|
||||||
|
gpu::TextureWithSampler,
|
||||||
|
shaders::ffi::{TextureClampMode, TextureFormat, TextureRef},
|
||||||
|
};
|
||||||
|
|
||||||
|
pub(crate) struct TextureWithView {
|
||||||
|
texture: wgpu::Texture,
|
||||||
|
view: wgpu::TextureView,
|
||||||
|
}
|
||||||
|
impl TextureWithView {
|
||||||
|
fn new(texture: wgpu::Texture) -> Self {
|
||||||
|
let view = texture.create_view(&wgpu::TextureViewDescriptor::default());
|
||||||
|
Self { texture, view }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) struct RenderTexture {
|
||||||
|
color_texture: Option<TextureWithView>,
|
||||||
|
depth_texture: Option<TextureWithView>,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) struct Texture {
|
||||||
|
texture: wgpu::Texture,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn create_static_texture_2d(
|
||||||
|
width: u32,
|
||||||
|
height: u32,
|
||||||
|
mips: u32,
|
||||||
|
format: TextureFormat,
|
||||||
|
data: &[u8],
|
||||||
|
label: &str,
|
||||||
|
) -> TextureRef {
|
||||||
|
let gpu = &get_app().gpu;
|
||||||
|
let texture = gpu.device.create_texture_with_data(
|
||||||
|
&gpu.queue,
|
||||||
|
&wgpu::TextureDescriptor {
|
||||||
|
label: Some(label),
|
||||||
|
size: wgpu::Extent3d { width, height, depth_or_array_layers: 1 },
|
||||||
|
mip_level_count: mips,
|
||||||
|
sample_count: 1,
|
||||||
|
dimension: wgpu::TextureDimension::D2,
|
||||||
|
format: match format {
|
||||||
|
TextureFormat::RGBA8 => wgpu::TextureFormat::Rgba8Unorm,
|
||||||
|
TextureFormat::R8 => wgpu::TextureFormat::R8Unorm,
|
||||||
|
TextureFormat::R32Float => wgpu::TextureFormat::R32Float,
|
||||||
|
TextureFormat::DXT1 => wgpu::TextureFormat::Bc1RgbaUnorm,
|
||||||
|
TextureFormat::DXT3 => wgpu::TextureFormat::Bc3RgbaUnorm,
|
||||||
|
TextureFormat::DXT5 => wgpu::TextureFormat::Bc5RgUnorm,
|
||||||
|
TextureFormat::BPTC => wgpu::TextureFormat::Bc7RgbaUnorm,
|
||||||
|
_ => todo!(),
|
||||||
|
},
|
||||||
|
usage: wgpu::TextureUsages::TEXTURE_BINDING,
|
||||||
|
},
|
||||||
|
data,
|
||||||
|
);
|
||||||
|
TextureRef { id: u32::MAX }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn create_render_texture(
|
||||||
|
width: u32,
|
||||||
|
height: u32,
|
||||||
|
// clamp_mode: TextureClampMode,
|
||||||
|
color_bind_count: u32,
|
||||||
|
depth_bind_count: u32,
|
||||||
|
label: &str,
|
||||||
|
) -> TextureRef {
|
||||||
|
let gpu = &get_app().gpu;
|
||||||
|
let color_texture = if color_bind_count > 0 {
|
||||||
|
Some(TextureWithView::new(gpu.device.create_texture(&wgpu::TextureDescriptor {
|
||||||
|
label: Some(format!("{} Color", label).as_str()),
|
||||||
|
size: wgpu::Extent3d { width, height, depth_or_array_layers: color_bind_count },
|
||||||
|
mip_level_count: 1,
|
||||||
|
sample_count: 1,
|
||||||
|
dimension: wgpu::TextureDimension::D2,
|
||||||
|
format: gpu.config.color_format,
|
||||||
|
usage: wgpu::TextureUsages::RENDER_ATTACHMENT,
|
||||||
|
})))
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
|
let depth_texture = if depth_bind_count > 0 {
|
||||||
|
Some(TextureWithView::new(gpu.device.create_texture(&wgpu::TextureDescriptor {
|
||||||
|
label: Some(format!("{} Depth", label).as_str()),
|
||||||
|
size: wgpu::Extent3d { width, height, depth_or_array_layers: depth_bind_count },
|
||||||
|
mip_level_count: 1,
|
||||||
|
sample_count: 1,
|
||||||
|
dimension: wgpu::TextureDimension::D2,
|
||||||
|
format: gpu.config.depth_format,
|
||||||
|
usage: wgpu::TextureUsages::RENDER_ATTACHMENT,
|
||||||
|
})))
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
|
// let (clamp_mode, border_color) = match clamp_mode {
|
||||||
|
// TextureClampMode::Repeat => (wgpu::AddressMode::Repeat, None),
|
||||||
|
// TextureClampMode::ClampToWhite => {
|
||||||
|
// (wgpu::AddressMode::ClampToBorder, Some(wgpu::SamplerBorderColor::OpaqueWhite))
|
||||||
|
// }
|
||||||
|
// TextureClampMode::ClampToBlack => {
|
||||||
|
// (wgpu::AddressMode::ClampToBorder, Some(wgpu::SamplerBorderColor::OpaqueBlack))
|
||||||
|
// }
|
||||||
|
// TextureClampMode::ClampToEdge => (wgpu::AddressMode::ClampToEdge, None),
|
||||||
|
// };
|
||||||
|
// let sampler = gpu.device.create_sampler(&wgpu::SamplerDescriptor {
|
||||||
|
// label: Some(format!("{} Color Sampler", label).as_str()),
|
||||||
|
// address_mode_u: clamp_mode,
|
||||||
|
// address_mode_v: clamp_mode,
|
||||||
|
// address_mode_w: clamp_mode,
|
||||||
|
// mag_filter: wgpu::FilterMode::Linear,
|
||||||
|
// min_filter: wgpu::FilterMode::Linear,
|
||||||
|
// mipmap_filter: wgpu::FilterMode::Linear,
|
||||||
|
// lod_min_clamp: 0.0,
|
||||||
|
// lod_max_clamp: f32::MAX,
|
||||||
|
// compare: None,
|
||||||
|
// anisotropy_clamp: None,
|
||||||
|
// border_color,
|
||||||
|
// });
|
||||||
|
RenderTexture { color_texture, depth_texture };
|
||||||
|
TextureRef { id: u32::MAX }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn drop_texture(handle: TextureRef) {}
|
|
@ -0,0 +1,171 @@
|
||||||
|
use bytemuck_derive::{Pod, Zeroable};
|
||||||
|
use cxx::{type_id, ExternType};
|
||||||
|
|
||||||
|
#[derive(Debug, Copy, Clone, Pod, Zeroable, Default)]
|
||||||
|
#[repr(C)]
|
||||||
|
pub struct CVector2f {
|
||||||
|
pub x: f32,
|
||||||
|
pub y: f32,
|
||||||
|
_p1: f32,
|
||||||
|
_p2: f32,
|
||||||
|
}
|
||||||
|
impl CVector2f {
|
||||||
|
pub const fn new(x: f32, y: f32) -> Self { Self { x, y, _p1: 0.0, _p2: 0.0 } }
|
||||||
|
}
|
||||||
|
unsafe impl ExternType for CVector2f {
|
||||||
|
type Id = type_id!("zeus::CVector2f");
|
||||||
|
type Kind = cxx::kind::Trivial;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Copy, Clone, Pod, Zeroable, Default)]
|
||||||
|
#[repr(C)]
|
||||||
|
pub struct CVector3f {
|
||||||
|
pub x: f32,
|
||||||
|
pub y: f32,
|
||||||
|
pub z: f32,
|
||||||
|
_p: f32,
|
||||||
|
}
|
||||||
|
impl CVector3f {
|
||||||
|
pub const fn new(x: f32, y: f32, z: f32) -> Self { Self { x, y, z, _p: 0.0 } }
|
||||||
|
}
|
||||||
|
unsafe impl ExternType for CVector3f {
|
||||||
|
type Id = type_id!("zeus::CVector3f");
|
||||||
|
type Kind = cxx::kind::Trivial;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Copy, Clone, Pod, Zeroable, Default)]
|
||||||
|
#[repr(C)]
|
||||||
|
pub struct CVector4f {
|
||||||
|
pub x: f32,
|
||||||
|
pub y: f32,
|
||||||
|
pub z: f32,
|
||||||
|
pub w: f32,
|
||||||
|
}
|
||||||
|
impl CVector4f {
|
||||||
|
pub const fn new(x: f32, y: f32, z: f32, w: f32) -> Self { Self { x, y, z, w } }
|
||||||
|
}
|
||||||
|
unsafe impl ExternType for CVector4f {
|
||||||
|
type Id = type_id!("zeus::CVector4f");
|
||||||
|
type Kind = cxx::kind::Trivial;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Copy, Clone, Pod, Zeroable, Default)]
|
||||||
|
#[repr(C)]
|
||||||
|
pub struct CColor {
|
||||||
|
pub r: f32,
|
||||||
|
pub g: f32,
|
||||||
|
pub b: f32,
|
||||||
|
pub a: f32,
|
||||||
|
}
|
||||||
|
impl CColor {
|
||||||
|
pub const fn new(r: f32, g: f32, b: f32, a: f32) -> Self { Self { r, g, b, a } }
|
||||||
|
}
|
||||||
|
unsafe impl ExternType for CColor {
|
||||||
|
type Id = type_id!("zeus::CColor");
|
||||||
|
type Kind = cxx::kind::Trivial;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Copy, Clone, Pod, Zeroable, Default)]
|
||||||
|
#[repr(C)]
|
||||||
|
pub struct CRectangle {
|
||||||
|
pub position: CVector2f,
|
||||||
|
pub size: CVector2f,
|
||||||
|
}
|
||||||
|
impl CRectangle {
|
||||||
|
pub const fn new(x: f32, y: f32, w: f32, h: f32) -> Self {
|
||||||
|
Self { position: CVector2f::new(x, y), size: CVector2f::new(w, h) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
unsafe impl ExternType for CRectangle {
|
||||||
|
type Id = type_id!("zeus::CRectangle");
|
||||||
|
type Kind = cxx::kind::Trivial;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Copy, Clone, Pod, Zeroable, Default)]
|
||||||
|
#[repr(C)]
|
||||||
|
pub struct CAABox {
|
||||||
|
pub min: CVector3f,
|
||||||
|
pub max: CVector3f,
|
||||||
|
}
|
||||||
|
impl CAABox {
|
||||||
|
pub const fn new(min: CVector3f, max: CVector3f) -> Self { Self { min, max } }
|
||||||
|
}
|
||||||
|
unsafe impl ExternType for CAABox {
|
||||||
|
type Id = type_id!("zeus::CAABox");
|
||||||
|
type Kind = cxx::kind::Trivial;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub const IDENTITY_MATRIX4F: CMatrix4f = CMatrix4f {
|
||||||
|
x: CVector4f::new(1.0, 0.0, 0.0, 0.0),
|
||||||
|
y: CVector4f::new(0.0, 1.0, 0.0, 0.0),
|
||||||
|
z: CVector4f::new(0.0, 0.0, 1.0, 0.0),
|
||||||
|
w: CVector4f::new(0.0, 0.0, 0.0, 1.0),
|
||||||
|
};
|
||||||
|
#[derive(Debug, Copy, Clone, Pod, Zeroable)]
|
||||||
|
#[repr(C)]
|
||||||
|
pub struct CMatrix4f {
|
||||||
|
pub x: CVector4f,
|
||||||
|
pub y: CVector4f,
|
||||||
|
pub z: CVector4f,
|
||||||
|
pub w: CVector4f,
|
||||||
|
}
|
||||||
|
impl CMatrix4f {
|
||||||
|
pub const fn new(x: CVector4f, y: CVector4f, z: CVector4f, w: CVector4f) -> Self {
|
||||||
|
Self { x, y, z, w }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl Default for CMatrix4f {
|
||||||
|
fn default() -> Self { IDENTITY_MATRIX4F }
|
||||||
|
}
|
||||||
|
unsafe impl ExternType for CMatrix4f {
|
||||||
|
type Id = type_id!("zeus::CMatrix4f");
|
||||||
|
type Kind = cxx::kind::Trivial;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cxx::bridge(namespace = "zeus")]
|
||||||
|
mod ffi {
|
||||||
|
unsafe extern "C++" {
|
||||||
|
include!("zeus/CVector2f.hpp");
|
||||||
|
include!("zeus/CVector3f.hpp");
|
||||||
|
include!("zeus/CVector4f.hpp");
|
||||||
|
include!("zeus/CMatrix4f.hpp");
|
||||||
|
include!("zeus/CColor.hpp");
|
||||||
|
include!("zeus/CRectangle.hpp");
|
||||||
|
include!("zeus/CAABox.hpp");
|
||||||
|
type CVector2f = crate::zeus::CVector2f;
|
||||||
|
type CVector3f = crate::zeus::CVector3f;
|
||||||
|
type CVector4f = crate::zeus::CVector4f;
|
||||||
|
type CMatrix4f = crate::zeus::CMatrix4f;
|
||||||
|
type CColor = crate::zeus::CColor;
|
||||||
|
type CRectangle = crate::zeus::CRectangle;
|
||||||
|
type CAABox = crate::zeus::CAABox;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<cgmath::Vector4<f32>> for CVector4f {
|
||||||
|
fn from(v: cgmath::Vector4<f32>) -> Self { Self { x: v.x, y: v.y, z: v.z, w: v.w } }
|
||||||
|
}
|
||||||
|
impl From<CVector4f> for cgmath::Vector4<f32> {
|
||||||
|
fn from(v: CVector4f) -> Self { Self { x: v.x, y: v.y, z: v.z, w: v.w } }
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<cgmath::Matrix4<f32>> for CMatrix4f {
|
||||||
|
fn from(m: cgmath::Matrix4<f32>) -> Self {
|
||||||
|
Self {
|
||||||
|
x: CVector4f::from(m.x),
|
||||||
|
y: CVector4f::from(m.y),
|
||||||
|
z: CVector4f::from(m.z),
|
||||||
|
w: CVector4f::from(m.w),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl From<CMatrix4f> for cgmath::Matrix4<f32> {
|
||||||
|
fn from(m: CMatrix4f) -> Self {
|
||||||
|
Self {
|
||||||
|
x: cgmath::Vector4::from(m.x),
|
||||||
|
y: cgmath::Vector4::from(m.y),
|
||||||
|
z: cgmath::Vector4::from(m.z),
|
||||||
|
w: cgmath::Vector4::from(m.w),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -260,31 +260,31 @@ void CNESEmulator::InitializeEmulator() {
|
||||||
// mainLoopRuns = nesPAL ? DOTS*ppuCycleTimer : DOTS*ppuCycleTimer;
|
// mainLoopRuns = nesPAL ? DOTS*ppuCycleTimer : DOTS*ppuCycleTimer;
|
||||||
// mainLoopPos = mainLoopRuns;
|
// mainLoopPos = mainLoopRuns;
|
||||||
|
|
||||||
CGraphics::CommitResources([this](boo::IGraphicsDataFactory::Context& ctx) {
|
// CGraphics::CommitResources([this](boo::IGraphicsDataFactory::Context& ctx) {
|
||||||
// Nearest-neighbor FTW!
|
// // Nearest-neighbor FTW!
|
||||||
m_texture = ctx.newDynamicTexture(VISIBLE_DOTS, linesToDraw, boo::TextureFormat::RGBA8,
|
// m_texture = ctx.newDynamicTexture(VISIBLE_DOTS, linesToDraw, boo::TextureFormat::RGBA8,
|
||||||
boo::TextureClampMode::ClampToEdgeNearest);
|
// boo::TextureClampMode::ClampToEdgeNearest);
|
||||||
if (ctx.platform() == boo::IGraphicsDataFactory::Platform::OpenGL) {
|
// if (ctx.platform() == boo::IGraphicsDataFactory::Platform::OpenGL) {
|
||||||
Vert verts[4] = {
|
// Vert verts[4] = {
|
||||||
{{-1.f, -1.f, 0.f}, {0.f, 1.f}},
|
// {{-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}, {0.f, 0.f}},
|
||||||
{{1.f, -1.f, 0.f}, {1.f, 1.f}},
|
// {{1.f, -1.f, 0.f}, {1.f, 1.f}},
|
||||||
{{1.f, 1.f, 0.f}, {1.f, 0.f}},
|
// {{1.f, 1.f, 0.f}, {1.f, 0.f}},
|
||||||
};
|
// };
|
||||||
m_vbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, verts, sizeof(Vert), 4);
|
// m_vbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, verts, sizeof(Vert), 4);
|
||||||
} else {
|
// } else {
|
||||||
Vert verts[4] = {
|
// Vert verts[4] = {
|
||||||
{{-1.f, 1.f, 0.f}, {0.f, 1.f}},
|
// {{-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}, {0.f, 0.f}},
|
||||||
{{1.f, 1.f, 0.f}, {1.f, 1.f}},
|
// {{1.f, 1.f, 0.f}, {1.f, 1.f}},
|
||||||
{{1.f, -1.f, 0.f}, {1.f, 0.f}},
|
// {{1.f, -1.f, 0.f}, {1.f, 0.f}},
|
||||||
};
|
// };
|
||||||
m_vbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, verts, sizeof(Vert), 4);
|
// m_vbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, verts, sizeof(Vert), 4);
|
||||||
}
|
// }
|
||||||
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
|
// m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
|
||||||
m_shadBind = CNESShader::BuildShaderDataBinding(ctx, m_vbo, m_uniBuf, m_texture);
|
// m_shadBind = CNESShader::BuildShaderDataBinding(ctx, m_vbo, m_uniBuf, m_texture);
|
||||||
return true;
|
// return true;
|
||||||
} BooTrace);
|
// } BooTrace);
|
||||||
|
|
||||||
// double useFreq = 223740;
|
// double useFreq = 223740;
|
||||||
double useFreq = apuGetFrequency();
|
double useFreq = apuGetFrequency();
|
||||||
|
@ -413,7 +413,8 @@ void CNESEmulator::NesEmuMainLoop(bool forceDraw) {
|
||||||
emuMainTimesSkipped++;
|
emuMainTimesSkipped++;
|
||||||
#endif
|
#endif
|
||||||
// printf("LC RENDER: %d\n", loopCount);
|
// printf("LC RENDER: %d\n", loopCount);
|
||||||
m_texture->load(textureImage, visibleImg);
|
// TODO TODO
|
||||||
|
// m_texture->load(textureImage, visibleImg);
|
||||||
emuRenderFrame = false;
|
emuRenderFrame = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -770,10 +771,10 @@ void CNESEmulator::Draw(const zeus::CColor& mulColor, bool filtering) {
|
||||||
|
|
||||||
Uniform uniform = {zeus::CMatrix4f{}, mulColor};
|
Uniform uniform = {zeus::CMatrix4f{}, mulColor};
|
||||||
uniform.m_matrix[0][0] = widthFac;
|
uniform.m_matrix[0][0] = widthFac;
|
||||||
m_uniBuf->load(&uniform, sizeof(Uniform));
|
// m_uniBuf->load(&uniform, sizeof(Uniform));
|
||||||
|
//
|
||||||
CGraphics::SetShaderDataBinding(m_shadBind);
|
// CGraphics::SetShaderDataBinding(m_shadBind);
|
||||||
CGraphics::DrawArray(0, 4);
|
// CGraphics::DrawArray(0, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CNESEmulator::LoadPassword(const u8* state) {
|
void CNESEmulator::LoadPassword(const u8* state) {
|
||||||
|
|
|
@ -2,9 +2,10 @@
|
||||||
|
|
||||||
#include "RetroTypes.hpp"
|
#include "RetroTypes.hpp"
|
||||||
#include "zeus/CColor.hpp"
|
#include "zeus/CColor.hpp"
|
||||||
#include "boo/graphicsdev/IGraphicsDataFactory.hpp"
|
//#include "boo/graphicsdev/IGraphicsDataFactory.hpp"
|
||||||
#include "boo/audiodev/IAudioVoice.hpp"
|
#include "boo/audiodev/IAudioVoice.hpp"
|
||||||
#include "zeus/CMatrix4f.hpp"
|
#include "zeus/CMatrix4f.hpp"
|
||||||
|
#include "Runtime/Graphics/CGraphics.hpp"
|
||||||
|
|
||||||
namespace metaforce {
|
namespace metaforce {
|
||||||
struct CFinalInput;
|
struct CFinalInput;
|
||||||
|
@ -34,10 +35,10 @@ private:
|
||||||
zeus::CColor m_color;
|
zeus::CColor m_color;
|
||||||
};
|
};
|
||||||
|
|
||||||
boo::ObjToken<boo::ITextureD> m_texture;
|
std::shared_ptr<aurora::TextureHandle> m_texture;
|
||||||
boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
|
// boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
|
||||||
boo::ObjToken<boo::IGraphicsBufferS> m_vbo;
|
// boo::ObjToken<boo::IGraphicsBufferS> m_vbo;
|
||||||
boo::ObjToken<boo::IShaderDataBinding> m_shadBind;
|
// boo::ObjToken<boo::IShaderDataBinding> m_shadBind;
|
||||||
|
|
||||||
std::unique_ptr<u8[]> m_audioBufBlock;
|
std::unique_ptr<u8[]> m_audioBufBlock;
|
||||||
u8* m_audioBufs[NUM_AUDIO_BUFFERS];
|
u8* m_audioBufs[NUM_AUDIO_BUFFERS];
|
||||||
|
|
|
@ -1,24 +1,28 @@
|
||||||
#include "CNESShader.hpp"
|
#include "CNESShader.hpp"
|
||||||
#include "Graphics/CGraphics.hpp"
|
#include "Graphics/CGraphics.hpp"
|
||||||
#include "hecl/Pipeline.hpp"
|
//#include "hecl/Pipeline.hpp"
|
||||||
|
|
||||||
namespace metaforce::MP1 {
|
namespace metaforce::MP1 {
|
||||||
|
|
||||||
boo::ObjToken<boo::IShaderPipeline> CNESShader::g_Pipeline;
|
//boo::ObjToken<boo::IShaderPipeline> CNESShader::g_Pipeline;
|
||||||
|
|
||||||
void CNESShader::Initialize() { g_Pipeline = hecl::conv->convert(Shader_CNESShader{}); }
|
void CNESShader::Initialize() {
|
||||||
|
// g_Pipeline = hecl::conv->convert(Shader_CNESShader{});
|
||||||
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::Shutdown() { g_Pipeline.reset(); }
|
//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::Shutdown() {
|
||||||
|
// g_Pipeline.reset();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace metaforce::MP1
|
} // namespace metaforce::MP1
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "boo/graphicsdev/IGraphicsDataFactory.hpp"
|
//#include "boo/graphicsdev/IGraphicsDataFactory.hpp"
|
||||||
|
|
||||||
namespace metaforce::MP1 {
|
namespace metaforce::MP1 {
|
||||||
|
|
||||||
|
@ -9,12 +9,12 @@ public:
|
||||||
static void Initialize();
|
static void Initialize();
|
||||||
static void Shutdown();
|
static void Shutdown();
|
||||||
|
|
||||||
static boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
// static boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||||
boo::ObjToken<boo::IGraphicsBufferS> vbo,
|
// boo::ObjToken<boo::IGraphicsBufferS> vbo,
|
||||||
boo::ObjToken<boo::IGraphicsBufferD> uniBuf,
|
// boo::ObjToken<boo::IGraphicsBufferD> uniBuf,
|
||||||
boo::ObjToken<boo::ITextureD> tex);
|
// boo::ObjToken<boo::ITextureD> tex);
|
||||||
|
//
|
||||||
static boo::ObjToken<boo::IShaderPipeline> g_Pipeline;
|
// static boo::ObjToken<boo::IShaderPipeline> g_Pipeline;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace metaforce::MP1
|
} // namespace metaforce::MP1
|
||||||
|
|
|
@ -3,11 +3,9 @@
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
#include "Runtime/CResFactory.hpp"
|
|
||||||
#include "Runtime/CToken.hpp"
|
#include "Runtime/CToken.hpp"
|
||||||
#include "Runtime/GameGlobalObjects.hpp"
|
#include "Runtime/GameGlobalObjects.hpp"
|
||||||
#include "Runtime/AutoMapper/CMappableObject.hpp"
|
#include "Runtime/AutoMapper/CMappableObject.hpp"
|
||||||
#include "Runtime/World/CGameArea.hpp"
|
|
||||||
#include "Runtime/World/CWorld.hpp"
|
#include "Runtime/World/CWorld.hpp"
|
||||||
|
|
||||||
namespace metaforce {
|
namespace metaforce {
|
||||||
|
@ -108,43 +106,43 @@ void CMapArea::PostConstruct() {
|
||||||
m_surfaces.emplace_back(x40_surfaceStart + j).PostConstruct(x44_buf.get(), index);
|
m_surfaces.emplace_back(x40_surfaceStart + j).PostConstruct(x44_buf.get(), index);
|
||||||
}
|
}
|
||||||
|
|
||||||
CGraphics::CommitResources([this, &index](boo::IGraphicsDataFactory::Context& ctx) {
|
// CGraphics::CommitResources([this, &index](boo::IGraphicsDataFactory::Context& ctx) {
|
||||||
m_vbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, m_verts.data(), 16, m_verts.size());
|
// 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_ibo = ctx.newStaticBuffer(boo::BufferUse::Index, index.data(), 4, index.size());
|
||||||
|
//
|
||||||
/* Only the map universe specifies Always; it draws a maximum of 1016 instances */
|
// /* Only the map universe specifies Always; it draws a maximum of 1016 instances */
|
||||||
size_t instCount = (xc_visibilityMode == EVisMode::Always) ? 1024 : 1;
|
// size_t instCount = (xc_visibilityMode == EVisMode::Always) ? 1024 : 1;
|
||||||
|
//
|
||||||
for (u32 i = 0; i < x30_surfaceCount; ++i) {
|
// for (u32 i = 0; i < x30_surfaceCount; ++i) {
|
||||||
CMapAreaSurface& surf = m_surfaces[i];
|
// CMapAreaSurface& surf = m_surfaces[i];
|
||||||
surf.m_instances.reserve(instCount);
|
// surf.m_instances.reserve(instCount);
|
||||||
for (u32 inst = 0; inst < instCount; ++inst) {
|
// for (u32 inst = 0; inst < instCount; ++inst) {
|
||||||
CMapAreaSurface::Instance& instance = surf.m_instances.emplace_back(ctx, m_vbo, m_ibo);
|
// CMapAreaSurface::Instance& instance = surf.m_instances.emplace_back(ctx, m_vbo, m_ibo);
|
||||||
|
//
|
||||||
athena::io::MemoryReader r(surf.x1c_outlineOffset, INT_MAX);
|
// athena::io::MemoryReader r(surf.x1c_outlineOffset, INT_MAX);
|
||||||
u32 outlineCount = r.readUint32Big();
|
// u32 outlineCount = r.readUint32Big();
|
||||||
|
//
|
||||||
std::vector<CLineRenderer>& linePrims = instance.m_linePrims;
|
// std::vector<CLineRenderer>& linePrims = instance.m_linePrims;
|
||||||
linePrims.reserve(outlineCount * 2);
|
// linePrims.reserve(outlineCount * 2);
|
||||||
for (u32 j = 0; j < 2; ++j) {
|
// for (u32 j = 0; j < 2; ++j) {
|
||||||
r.seek(4, athena::SeekOrigin::Begin);
|
// r.seek(4, athena::SeekOrigin::Begin);
|
||||||
for (u32 k = 0; k < outlineCount; ++k) {
|
// for (u32 k = 0; k < outlineCount; ++k) {
|
||||||
const u32 count = r.readUint32Big();
|
// const u32 count = r.readUint32Big();
|
||||||
r.seek(count);
|
// r.seek(count);
|
||||||
r.seekAlign4();
|
// r.seekAlign4();
|
||||||
linePrims.emplace_back(ctx, CLineRenderer::EPrimitiveMode::LineStrip, count, nullptr, false, false, true);
|
// linePrims.emplace_back(ctx, CLineRenderer::EPrimitiveMode::LineStrip, count, nullptr, false, false, true);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
for (u32 i = 0; i < x28_mappableObjCount; ++i) {
|
// for (u32 i = 0; i < x28_mappableObjCount; ++i) {
|
||||||
CMappableObject& mapObj = m_mappableObjects[i];
|
// CMappableObject& mapObj = m_mappableObjects[i];
|
||||||
if (CMappableObject::IsDoorType(mapObj.GetType()))
|
// if (CMappableObject::IsDoorType(mapObj.GetType()))
|
||||||
mapObj.CreateDoorSurface(ctx);
|
// mapObj.CreateDoorSurface(ctx);
|
||||||
}
|
// }
|
||||||
return true;
|
// return true;
|
||||||
} BooTrace);
|
// } BooTrace);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CMapArea::GetIsVisibleToAutoMapper(bool worldVis, bool areaVis) const {
|
bool CMapArea::GetIsVisibleToAutoMapper(bool worldVis, bool areaVis) const {
|
||||||
|
|
|
@ -3,13 +3,13 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "Runtime/CResFactory.hpp"
|
|
||||||
#include "Runtime/RetroTypes.hpp"
|
|
||||||
#include "Runtime/AutoMapper/CMappableObject.hpp"
|
#include "Runtime/AutoMapper/CMappableObject.hpp"
|
||||||
|
#include "Runtime/CResFactory.hpp"
|
||||||
#include "Runtime/Graphics/CLineRenderer.hpp"
|
#include "Runtime/Graphics/CLineRenderer.hpp"
|
||||||
#include "Runtime/Graphics/Shaders/CMapSurfaceShader.hpp"
|
#include "Runtime/Graphics/Shaders/CMapSurfaceShader.hpp"
|
||||||
|
#include "Runtime/RetroTypes.hpp"
|
||||||
|
|
||||||
#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
//#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
||||||
|
|
||||||
#include <zeus/CAABox.hpp>
|
#include <zeus/CAABox.hpp>
|
||||||
#include <zeus/CVector3f.hpp>
|
#include <zeus/CVector3f.hpp>
|
||||||
|
@ -29,9 +29,9 @@ public:
|
||||||
struct Instance {
|
struct Instance {
|
||||||
CMapSurfaceShader m_surfacePrims;
|
CMapSurfaceShader m_surfacePrims;
|
||||||
std::vector<CLineRenderer> m_linePrims;
|
std::vector<CLineRenderer> m_linePrims;
|
||||||
Instance(boo::IGraphicsDataFactory::Context& ctx, const boo::ObjToken<boo::IGraphicsBufferS>& vbo,
|
Instance(aurora::ArrayRef<zeus::CVector3f> vbo,
|
||||||
const boo::ObjToken<boo::IGraphicsBufferS>& ibo)
|
aurora::ArrayRef<u16> ibo)
|
||||||
: m_surfacePrims(ctx, vbo, ibo) {}
|
: m_surfacePrims(vbo, ibo) {}
|
||||||
Instance(Instance&&) = default;
|
Instance(Instance&&) = default;
|
||||||
Instance& operator=(Instance&&) = default;
|
Instance& operator=(Instance&&) = default;
|
||||||
};
|
};
|
||||||
|
@ -65,8 +65,8 @@ private:
|
||||||
u8* x40_surfaceStart;
|
u8* x40_surfaceStart;
|
||||||
std::vector<CMapAreaSurface> m_surfaces;
|
std::vector<CMapAreaSurface> m_surfaces;
|
||||||
std::unique_ptr<u8[]> x44_buf;
|
std::unique_ptr<u8[]> x44_buf;
|
||||||
boo::ObjToken<boo::IGraphicsBufferS> m_vbo;
|
// boo::ObjToken<boo::IGraphicsBufferS> m_vbo;
|
||||||
boo::ObjToken<boo::IGraphicsBufferS> m_ibo;
|
// boo::ObjToken<boo::IGraphicsBufferS> m_ibo;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit CMapArea(CInputStream& in, u32 size);
|
explicit CMapArea(CInputStream& in, u32 size);
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#include "Runtime/AutoMapper/CMappableObject.hpp"
|
#include "Runtime/AutoMapper/CMappableObject.hpp"
|
||||||
|
|
||||||
|
#include "Runtime/AutoMapper/CMapWorldInfo.hpp"
|
||||||
#include "Runtime/CSimplePool.hpp"
|
#include "Runtime/CSimplePool.hpp"
|
||||||
#include "Runtime/CToken.hpp"
|
#include "Runtime/CToken.hpp"
|
||||||
#include "Runtime/AutoMapper/CMapWorldInfo.hpp"
|
|
||||||
#include "Runtime/Camera/CCameraFilter.hpp"
|
#include "Runtime/Camera/CCameraFilter.hpp"
|
||||||
#include "Runtime/GameGlobalObjects.hpp"
|
#include "Runtime/GameGlobalObjects.hpp"
|
||||||
#include "Runtime/Graphics/CTexture.hpp"
|
#include "Runtime/Graphics/CTexture.hpp"
|
||||||
|
@ -10,7 +10,7 @@
|
||||||
namespace metaforce {
|
namespace metaforce {
|
||||||
std::array<zeus::CVector3f, 8> CMappableObject::skDoorVerts{};
|
std::array<zeus::CVector3f, 8> CMappableObject::skDoorVerts{};
|
||||||
|
|
||||||
constexpr std::array<u32, 24> DoorIndices{
|
std::array<u16, 24> CMappableObject::skDoorIndices{
|
||||||
6, 4, 2, 0, 3, 1, 7, 5, 1, 0, 5, 4, 7, 6, 3, 2, 3, 2, 1, 0, 5, 4, 7, 6,
|
6, 4, 2, 0, 3, 1, 7, 5, 1, 0, 5, 4, 7, 6, 3, 2, 3, 2, 1, 0, 5, 4, 7, 6,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ void CMappableObject::Draw(int curArea, const CMapWorldInfo& mwInfo, float alpha
|
||||||
DoorSurface& ds = *m_doorSurface;
|
DoorSurface& ds = *m_doorSurface;
|
||||||
ds.m_surface.draw(colors.first, s * 4, 4);
|
ds.m_surface.draw(colors.first, s * 4, 4);
|
||||||
CLineRenderer& line = ds.m_outline;
|
CLineRenderer& line = ds.m_outline;
|
||||||
const u32* baseIdx = &DoorIndices[s * 4];
|
const u16* baseIdx = &skDoorIndices[s * 4];
|
||||||
line.Reset();
|
line.Reset();
|
||||||
line.AddVertex(skDoorVerts[baseIdx[0]], colors.second, 1.f);
|
line.AddVertex(skDoorVerts[baseIdx[0]], colors.second, 1.f);
|
||||||
line.AddVertex(skDoorVerts[baseIdx[1]], colors.second, 1.f);
|
line.AddVertex(skDoorVerts[baseIdx[1]], colors.second, 1.f);
|
||||||
|
@ -186,7 +186,7 @@ void CMappableObject::DrawDoorSurface(int curArea, const CMapWorldInfo& mwInfo,
|
||||||
DoorSurface& ds = *m_doorSurface;
|
DoorSurface& ds = *m_doorSurface;
|
||||||
ds.m_surface.draw(colors.first, surfIdx * 4, 4);
|
ds.m_surface.draw(colors.first, surfIdx * 4, 4);
|
||||||
CLineRenderer& line = ds.m_outline;
|
CLineRenderer& line = ds.m_outline;
|
||||||
const u32* baseIdx = &DoorIndices[surfIdx * 4];
|
const u16* baseIdx = &skDoorIndices[surfIdx * 4];
|
||||||
line.Reset();
|
line.Reset();
|
||||||
line.AddVertex(skDoorVerts[baseIdx[0]], colors.second, 1.f);
|
line.AddVertex(skDoorVerts[baseIdx[0]], colors.second, 1.f);
|
||||||
line.AddVertex(skDoorVerts[baseIdx[1]], colors.second, 1.f);
|
line.AddVertex(skDoorVerts[baseIdx[1]], colors.second, 1.f);
|
||||||
|
@ -236,9 +236,6 @@ bool CMappableObject::IsVisibleToAutoMapper(bool worldVis, const CMapWorldInfo&
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boo::ObjToken<boo::IGraphicsBufferS> CMappableObject::g_doorVbo;
|
|
||||||
boo::ObjToken<boo::IGraphicsBufferS> CMappableObject::g_doorIbo;
|
|
||||||
|
|
||||||
void CMappableObject::ReadAutoMapperTweaks(const ITweakAutoMapper& tweaks) {
|
void CMappableObject::ReadAutoMapperTweaks(const ITweakAutoMapper& tweaks) {
|
||||||
const zeus::CVector3f& center = tweaks.GetDoorCenter();
|
const zeus::CVector3f& center = tweaks.GetDoorCenter();
|
||||||
const zeus::simd_floats centerF(center.mSimd);
|
const zeus::simd_floats centerF(center.mSimd);
|
||||||
|
@ -254,15 +251,15 @@ void CMappableObject::ReadAutoMapperTweaks(const ITweakAutoMapper& tweaks) {
|
||||||
doorVerts[6].assign(.2f * -centerF[2], centerF[1], 0.f);
|
doorVerts[6].assign(.2f * -centerF[2], centerF[1], 0.f);
|
||||||
doorVerts[7].assign(.2f * -centerF[2], centerF[1], 2.f * centerF[0]);
|
doorVerts[7].assign(.2f * -centerF[2], centerF[1], 2.f * centerF[0]);
|
||||||
|
|
||||||
CGraphics::CommitResources([](boo::IGraphicsDataFactory::Context& ctx) {
|
// CGraphics::CommitResources([](boo::IGraphicsDataFactory::Context& ctx) {
|
||||||
g_doorVbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, skDoorVerts.data(), 16, skDoorVerts.size());
|
// g_doorVbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, skDoorVerts.data(), 16, skDoorVerts.size());
|
||||||
g_doorIbo = ctx.newStaticBuffer(boo::BufferUse::Index, DoorIndices.data(), 4, DoorIndices.size());
|
// g_doorIbo = ctx.newStaticBuffer(boo::BufferUse::Index, DoorIndices.data(), 4, DoorIndices.size());
|
||||||
return true;
|
// return true;
|
||||||
} BooTrace);
|
// } BooTrace);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMappableObject::Shutdown() {
|
void CMappableObject::Shutdown() {
|
||||||
g_doorVbo.reset();
|
// g_doorVbo.reset();
|
||||||
g_doorIbo.reset();
|
// g_doorIbo.reset();
|
||||||
}
|
}
|
||||||
} // namespace metaforce
|
} // namespace metaforce
|
||||||
|
|
|
@ -5,10 +5,10 @@
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "Runtime/GameGlobalObjects.hpp"
|
#include "Runtime/GameGlobalObjects.hpp"
|
||||||
#include "Runtime/RetroTypes.hpp"
|
|
||||||
#include "Runtime/Graphics/CLineRenderer.hpp"
|
#include "Runtime/Graphics/CLineRenderer.hpp"
|
||||||
#include "Runtime/Graphics/Shaders/CMapSurfaceShader.hpp"
|
#include "Runtime/Graphics/Shaders/CMapSurfaceShader.hpp"
|
||||||
#include "Runtime/Graphics/Shaders/CTexturedQuadFilter.hpp"
|
#include "Runtime/Graphics/Shaders/CTexturedQuadFilter.hpp"
|
||||||
|
#include "Runtime/RetroTypes.hpp"
|
||||||
|
|
||||||
#include <zeus/CAABox.hpp>
|
#include <zeus/CAABox.hpp>
|
||||||
#include <zeus/CTransform.hpp>
|
#include <zeus/CTransform.hpp>
|
||||||
|
@ -18,9 +18,6 @@ class CMapWorldInfo;
|
||||||
class CStateManager;
|
class CStateManager;
|
||||||
|
|
||||||
class CMappableObject {
|
class CMappableObject {
|
||||||
static boo::ObjToken<boo::IGraphicsBufferS> g_doorVbo;
|
|
||||||
static boo::ObjToken<boo::IGraphicsBufferS> g_doorIbo;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum class EMappableObjectType {
|
enum class EMappableObjectType {
|
||||||
BlueDoor = 0,
|
BlueDoor = 0,
|
||||||
|
@ -54,6 +51,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static std::array<zeus::CVector3f, 8> skDoorVerts;
|
static std::array<zeus::CVector3f, 8> skDoorVerts;
|
||||||
|
static std::array<u16, 24> skDoorIndices;
|
||||||
|
|
||||||
EMappableObjectType x0_type;
|
EMappableObjectType x0_type;
|
||||||
EVisMode x4_visibilityMode;
|
EVisMode x4_visibilityMode;
|
||||||
|
@ -64,9 +62,9 @@ private:
|
||||||
struct DoorSurface {
|
struct DoorSurface {
|
||||||
CMapSurfaceShader m_surface;
|
CMapSurfaceShader m_surface;
|
||||||
CLineRenderer m_outline;
|
CLineRenderer m_outline;
|
||||||
explicit DoorSurface(boo::IGraphicsDataFactory::Context& ctx)
|
explicit DoorSurface()
|
||||||
: m_surface(ctx, g_doorVbo, g_doorIbo)
|
: m_surface(aurora::ArrayRef{skDoorVerts}, aurora::ArrayRef{skDoorIndices})
|
||||||
, m_outline(ctx, CLineRenderer::EPrimitiveMode::LineLoop, 5, nullptr, false, false, true) {}
|
, m_outline(CLineRenderer::EPrimitiveMode::LineLoop, 5, nullptr, false, false, true) {}
|
||||||
};
|
};
|
||||||
std::optional<DoorSurface> m_doorSurface;
|
std::optional<DoorSurface> m_doorSurface;
|
||||||
std::optional<CTexturedQuadFilter> m_texQuadFilter;
|
std::optional<CTexturedQuadFilter> m_texQuadFilter;
|
||||||
|
@ -87,7 +85,7 @@ public:
|
||||||
bool IsDoorConnectedToVisitedArea(const CStateManager&) const;
|
bool IsDoorConnectedToVisitedArea(const CStateManager&) const;
|
||||||
bool IsVisibleToAutoMapper(bool worldVis, const CMapWorldInfo& mwInfo) const;
|
bool IsVisibleToAutoMapper(bool worldVis, const CMapWorldInfo& mwInfo) const;
|
||||||
bool GetIsSeen() 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 void ReadAutoMapperTweaks(const ITweakAutoMapper&);
|
||||||
static bool GetTweakIsMapVisibilityCheat();
|
static bool GetTweakIsMapVisibilityCheat();
|
||||||
|
|
|
@ -7,11 +7,14 @@
|
||||||
|
|
||||||
namespace metaforce {
|
namespace metaforce {
|
||||||
|
|
||||||
hecl::ProjectPath CDvdFile::m_DvdRoot;
|
std::unique_ptr<nod::DiscBase> CDvdFile::m_DvdRoot;
|
||||||
std::unordered_map<std::string, std::string> CDvdFile::m_caseInsensitiveMap;
|
// std::unordered_map<std::string, std::string> CDvdFile::m_caseInsensitiveMap;
|
||||||
|
|
||||||
class CFileDvdRequest : public IDvdRequest {
|
class CFileDvdRequest : public IDvdRequest {
|
||||||
std::shared_ptr<athena::io::FileReader> m_reader;
|
std::shared_ptr<nod::IPartReadStream> m_reader;
|
||||||
|
uint64_t m_begin;
|
||||||
|
uint64_t m_size;
|
||||||
|
|
||||||
void* m_buf;
|
void* m_buf;
|
||||||
u32 m_len;
|
u32 m_len;
|
||||||
ESeekOrigin m_whence;
|
ESeekOrigin m_whence;
|
||||||
|
@ -40,18 +43,43 @@ public:
|
||||||
[[nodiscard]] EMediaType GetMediaType() const override { return EMediaType::File; }
|
[[nodiscard]] EMediaType GetMediaType() const override { return EMediaType::File; }
|
||||||
|
|
||||||
CFileDvdRequest(CDvdFile& file, void* buf, u32 len, ESeekOrigin whence, int off, std::function<void(u32)>&& cb)
|
CFileDvdRequest(CDvdFile& file, void* buf, u32 len, ESeekOrigin whence, int off, std::function<void(u32)>&& cb)
|
||||||
: m_reader(file.m_reader), m_buf(buf), m_len(len), m_whence(whence), m_offset(off), m_callback(std::move(cb)) {}
|
: m_reader(file.m_reader)
|
||||||
|
, m_begin(file.m_begin)
|
||||||
|
, m_size(file.m_size)
|
||||||
|
, m_buf(buf)
|
||||||
|
, m_len(len)
|
||||||
|
, m_whence(whence)
|
||||||
|
, m_offset(off)
|
||||||
|
, m_callback(std::move(cb)) {}
|
||||||
|
|
||||||
void DoRequest() {
|
void DoRequest() {
|
||||||
if (m_cancel.load()) {
|
if (m_cancel.load()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
u32 readLen;
|
u32 readLen = 0;
|
||||||
if (m_whence == ESeekOrigin::Cur && m_offset == 0) {
|
if (m_whence == ESeekOrigin::Cur && m_offset == 0) {
|
||||||
readLen = m_reader->readBytesToBuf(m_buf, m_len);
|
readLen = m_reader->read(m_buf, m_len);
|
||||||
} else {
|
} else {
|
||||||
m_reader->seek(m_offset, athena::SeekOrigin(m_whence));
|
int seek = 0;
|
||||||
readLen = m_reader->readBytesToBuf(m_buf, m_len);
|
int64_t offset = m_offset;
|
||||||
|
switch (m_whence) {
|
||||||
|
case ESeekOrigin::Begin: {
|
||||||
|
seek = SEEK_SET;
|
||||||
|
offset += int64_t(m_begin);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case ESeekOrigin::End: {
|
||||||
|
seek = SEEK_SET;
|
||||||
|
offset += int64_t(m_begin) + int64_t(m_size);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case ESeekOrigin::Cur: {
|
||||||
|
seek = SEEK_CUR;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
m_reader->seek(offset, seek);
|
||||||
|
readLen = m_reader->read(m_buf, m_len);
|
||||||
}
|
}
|
||||||
if (m_callback) {
|
if (m_callback) {
|
||||||
m_callback(readLen);
|
m_callback(readLen);
|
||||||
|
@ -67,6 +95,15 @@ std::mutex CDvdFile::m_WaitMutex;
|
||||||
std::atomic_bool CDvdFile::m_WorkerRun = {false};
|
std::atomic_bool CDvdFile::m_WorkerRun = {false};
|
||||||
std::vector<std::shared_ptr<IDvdRequest>> CDvdFile::m_RequestQueue;
|
std::vector<std::shared_ptr<IDvdRequest>> CDvdFile::m_RequestQueue;
|
||||||
|
|
||||||
|
CDvdFile::CDvdFile(std::string_view path) : x18_path(path) {
|
||||||
|
auto* node = ResolvePath(path);
|
||||||
|
if (node != nullptr && node->getKind() == nod::Node::Kind::File) {
|
||||||
|
m_reader = node->beginReadStream();
|
||||||
|
m_begin = m_reader->position();
|
||||||
|
m_size = node->size();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CDvdFile::WorkerProc() {
|
void CDvdFile::WorkerProc() {
|
||||||
logvisor::RegisterThreadName("CDvdFile");
|
logvisor::RegisterThreadName("CDvdFile");
|
||||||
OPTICK_THREAD("CDvdFile");
|
OPTICK_THREAD("CDvdFile");
|
||||||
|
@ -103,42 +140,72 @@ std::shared_ptr<IDvdRequest> CDvdFile::AsyncSeekRead(void* buf, u32 len, ESeekOr
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
hecl::ProjectPath CDvdFile::ResolvePath(std::string_view path) {
|
u32 CDvdFile::SyncSeekRead(void* buf, u32 len, ESeekOrigin whence, int offset) {
|
||||||
auto start = path.begin();
|
int seek = 0;
|
||||||
while (*start == '/') {
|
switch (whence) {
|
||||||
++start;
|
case ESeekOrigin::Begin: {
|
||||||
|
seek = SEEK_SET;
|
||||||
|
offset += int64_t(m_begin);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
std::string lowerChStr(start, path.end());
|
case ESeekOrigin::End: {
|
||||||
std::transform(lowerChStr.begin(), lowerChStr.end(), lowerChStr.begin(), ::tolower);
|
seek = SEEK_SET;
|
||||||
auto search = m_caseInsensitiveMap.find(lowerChStr);
|
offset += int64_t(m_begin) + int64_t(m_size);
|
||||||
if (search == m_caseInsensitiveMap.end()) {
|
break;
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
return hecl::ProjectPath(m_DvdRoot, search->second);
|
case ESeekOrigin::Cur: {
|
||||||
|
seek = SEEK_CUR;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
m_reader->seek(offset, seek);
|
||||||
|
return m_reader->read(buf, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDvdFile::RecursiveBuildCaseInsensitiveMap(const hecl::ProjectPath& path, std::string::size_type prefixLen) {
|
nod::Node* CDvdFile::ResolvePath(std::string_view path) {
|
||||||
for (const auto& p : path.enumerateDir()) {
|
if (!m_DvdRoot) {
|
||||||
if (p.m_isDir) {
|
return nullptr;
|
||||||
RecursiveBuildCaseInsensitiveMap(hecl::ProjectPath(path, p.m_name), prefixLen);
|
}
|
||||||
|
if (path.starts_with('/')) {
|
||||||
|
path.remove_prefix(1);
|
||||||
|
}
|
||||||
|
auto* node = &m_DvdRoot->getDataPartition()->getFSTRoot();
|
||||||
|
while (node != nullptr && !path.empty()) {
|
||||||
|
std::string component;
|
||||||
|
auto end = path.find('/');
|
||||||
|
if (end != std::string_view::npos) {
|
||||||
|
component = path.substr(0, end);
|
||||||
|
path.remove_prefix(component.size() + 1);
|
||||||
} else {
|
} else {
|
||||||
hecl::ProjectPath ch(path, p.m_name);
|
component = path;
|
||||||
std::string chStr(ch.getAbsolutePath().begin() + prefixLen, ch.getAbsolutePath().end());
|
path.remove_prefix(component.size());
|
||||||
std::string lowerChStr(chStr);
|
}
|
||||||
hecl::ToLower(lowerChStr);
|
std::transform(component.begin(), component.end(), component.begin(), ::tolower);
|
||||||
m_caseInsensitiveMap[lowerChStr] = chStr;
|
auto* tmpNode = node;
|
||||||
|
node = nullptr;
|
||||||
|
for (auto& item : *tmpNode) {
|
||||||
|
const auto name = item.getName();
|
||||||
|
if (std::equal(component.begin(), component.end(), name.begin(), name.end(),
|
||||||
|
[](char a, char b) { return a == tolower(b); })) {
|
||||||
|
node = &item;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDvdFile::Initialize(const hecl::ProjectPath& path) {
|
bool CDvdFile::Initialize(const std::string_view& path) {
|
||||||
m_DvdRoot = path;
|
|
||||||
RecursiveBuildCaseInsensitiveMap(path, path.getAbsolutePath().length() + 1);
|
|
||||||
if (m_WorkerRun.load()) {
|
if (m_WorkerRun.load()) {
|
||||||
return;
|
return true;
|
||||||
|
}
|
||||||
|
m_DvdRoot = nod::OpenDiscFromImage(path);
|
||||||
|
if (!m_DvdRoot) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
m_WorkerRun.store(true);
|
m_WorkerRun.store(true);
|
||||||
m_WorkerThread = std::thread(WorkerProc);
|
m_WorkerThread = std::thread(WorkerProc);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDvdFile::Shutdown() {
|
void CDvdFile::Shutdown() {
|
||||||
|
|
|
@ -12,6 +12,8 @@
|
||||||
#include "Runtime/RetroTypes.hpp"
|
#include "Runtime/RetroTypes.hpp"
|
||||||
|
|
||||||
#include <athena/FileReader.hpp>
|
#include <athena/FileReader.hpp>
|
||||||
|
#include <nod/nod.hpp>
|
||||||
|
#include <nod/DiscBase.hpp>
|
||||||
|
|
||||||
namespace metaforce {
|
namespace metaforce {
|
||||||
|
|
||||||
|
@ -23,8 +25,8 @@ class IDvdRequest;
|
||||||
class CDvdFile {
|
class CDvdFile {
|
||||||
friend class CResLoader;
|
friend class CResLoader;
|
||||||
friend class CFileDvdRequest;
|
friend class CFileDvdRequest;
|
||||||
static hecl::ProjectPath m_DvdRoot;
|
static std::unique_ptr<nod::DiscBase> m_DvdRoot;
|
||||||
static std::unordered_map<std::string, std::string> m_caseInsensitiveMap;
|
// static std::unordered_map<std::string, std::string> m_caseInsensitiveMap;
|
||||||
static std::thread m_WorkerThread;
|
static std::thread m_WorkerThread;
|
||||||
static std::mutex m_WorkerMutex;
|
static std::mutex m_WorkerMutex;
|
||||||
static std::condition_variable m_WorkerCV;
|
static std::condition_variable m_WorkerCV;
|
||||||
|
@ -34,32 +36,33 @@ class CDvdFile {
|
||||||
static void WorkerProc();
|
static void WorkerProc();
|
||||||
|
|
||||||
std::string x18_path;
|
std::string x18_path;
|
||||||
std::shared_ptr<athena::io::FileReader> m_reader;
|
std::shared_ptr<nod::IPartReadStream> m_reader;
|
||||||
|
uint64_t m_begin;
|
||||||
|
uint64_t m_size;
|
||||||
|
|
||||||
static hecl::ProjectPath ResolvePath(std::string_view path);
|
static nod::Node* ResolvePath(std::string_view path);
|
||||||
static void RecursiveBuildCaseInsensitiveMap(const hecl::ProjectPath& path, std::string::size_type prefixLen);
|
// static void RecursiveBuildCaseInsensitiveMap(const hecl::ProjectPath& path, std::string::size_type prefixLen);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void Initialize(const hecl::ProjectPath& path);
|
static bool Initialize(const std::string_view& path);
|
||||||
static void Shutdown();
|
static void Shutdown();
|
||||||
|
|
||||||
CDvdFile(std::string_view path)
|
CDvdFile(std::string_view path);
|
||||||
: x18_path(path), m_reader(std::make_shared<athena::io::FileReader>(ResolvePath(path).getAbsolutePath())) {}
|
operator bool() const { return m_reader.operator bool(); }
|
||||||
operator bool() const { return m_reader->isOpen(); }
|
void UpdateFilePos(int pos) { m_reader->seek(pos, SEEK_SET); }
|
||||||
void UpdateFilePos(int pos) { m_reader->seek(pos, athena::SeekOrigin::Begin); }
|
static bool FileExists(std::string_view path) {
|
||||||
static bool FileExists(std::string_view path) { return ResolvePath(path).isFile(); }
|
nod::Node* node = ResolvePath(path);
|
||||||
void CloseFile() { m_reader->close(); }
|
return node != nullptr && node->getKind() == nod::Node::Kind::File;
|
||||||
|
}
|
||||||
|
void CloseFile() { m_reader.reset(); }
|
||||||
std::shared_ptr<IDvdRequest> AsyncSeekRead(void* buf, u32 len, ESeekOrigin whence, int off,
|
std::shared_ptr<IDvdRequest> AsyncSeekRead(void* buf, u32 len, ESeekOrigin whence, int off,
|
||||||
std::function<void(u32)>&& cb = {});
|
std::function<void(u32)>&& cb = {});
|
||||||
u32 SyncSeekRead(void* buf, u32 len, ESeekOrigin whence, int offset) {
|
u32 SyncSeekRead(void* buf, u32 len, ESeekOrigin whence, int offset);
|
||||||
m_reader->seek(offset, athena::SeekOrigin(whence));
|
|
||||||
return m_reader->readBytesToBuf(buf, len);
|
|
||||||
}
|
|
||||||
std::shared_ptr<IDvdRequest> AsyncRead(void* buf, u32 len, std::function<void(u32)>&& cb = {}) {
|
std::shared_ptr<IDvdRequest> AsyncRead(void* buf, u32 len, std::function<void(u32)>&& cb = {}) {
|
||||||
return AsyncSeekRead(buf, len, ESeekOrigin::Cur, 0, std::move(cb));
|
return AsyncSeekRead(buf, len, ESeekOrigin::Cur, 0, std::move(cb));
|
||||||
}
|
}
|
||||||
u32 SyncRead(void* buf, u32 len) { return m_reader->readBytesToBuf(buf, len); }
|
u32 SyncRead(void* buf, u32 len) { return m_reader->read(buf, len); }
|
||||||
u64 Length() const { return m_reader->length(); }
|
u64 Length() const { return m_size; }
|
||||||
std::string_view GetPath() const { return x18_path; }
|
std::string_view GetPath() const { return x18_path; }
|
||||||
};
|
};
|
||||||
} // namespace metaforce
|
} // namespace metaforce
|
||||||
|
|
|
@ -287,7 +287,7 @@ void CGameOptions::ApplyGamma() {
|
||||||
gammaT = gammaT * 0.5f + 0.5f;
|
gammaT = gammaT * 0.5f + 0.5f;
|
||||||
if (zeus::close_enough(gammaT, 1.f, 0.05f))
|
if (zeus::close_enough(gammaT, 1.f, 0.05f))
|
||||||
gammaT = 1.f;
|
gammaT = 1.f;
|
||||||
CGraphics::g_BooFactory->setDisplayGamma(gammaT);
|
// CGraphics::g_BooFactory->setDisplayGamma(gammaT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGameOptions::SetGamma(s32 value, bool apply) {
|
void CGameOptions::SetGamma(s32 value, bool apply) {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
#include <hecl/Pipeline.hpp>
|
#include <iostream>
|
||||||
|
|
||||||
#include "boo/boo.hpp"
|
#include "boo/boo.hpp"
|
||||||
#include "logvisor/logvisor.hpp"
|
#include "logvisor/logvisor.hpp"
|
||||||
|
@ -20,6 +20,10 @@
|
||||||
* (used by MSVC to definitively link DataSpecs) */
|
* (used by MSVC to definitively link DataSpecs) */
|
||||||
#include "DataSpecRegistry.hpp"
|
#include "DataSpecRegistry.hpp"
|
||||||
|
|
||||||
|
#include "Graphics/include/aurora.hpp"
|
||||||
|
#include "aurora.h"
|
||||||
|
#include "aurora_shaders.h"
|
||||||
|
|
||||||
using namespace std::literals;
|
using namespace std::literals;
|
||||||
|
|
||||||
static logvisor::Module AthenaLog("Athena");
|
static logvisor::Module AthenaLog("Athena");
|
||||||
|
@ -151,21 +155,21 @@ private:
|
||||||
boo::SWindowRect m_lastRect;
|
boo::SWindowRect m_lastRect;
|
||||||
bool m_rectDirty = false;
|
bool m_rectDirty = false;
|
||||||
bool m_windowInvalid = false;
|
bool m_windowInvalid = false;
|
||||||
ImGuiWindowCallback m_imguiCallback;
|
// ImGuiWindowCallback m_imguiCallback;
|
||||||
|
|
||||||
void resized(const boo::SWindowRect& rect, bool sync) override {
|
void resized(const boo::SWindowRect& rect, bool sync) override {
|
||||||
m_lastRect = rect;
|
m_lastRect = rect;
|
||||||
m_rectDirty = true;
|
m_rectDirty = true;
|
||||||
m_imguiCallback.resized(rect, sync);
|
// m_imguiCallback.resized(rect, sync);
|
||||||
}
|
}
|
||||||
|
|
||||||
void mouseDown(const boo::SWindowCoord& coord, boo::EMouseButton button, boo::EModifierKey mods) override {
|
void mouseDown(const boo::SWindowCoord& coord, boo::EMouseButton button, boo::EModifierKey mods) override {
|
||||||
if (!ImGuiWindowCallback::m_mouseCaptured && g_mainMP1) {
|
// if (!ImGuiWindowCallback::m_mouseCaptured && g_mainMP1) {
|
||||||
if (MP1::CGameArchitectureSupport* as = g_mainMP1->GetArchSupport()) {
|
// if (MP1::CGameArchitectureSupport* as = g_mainMP1->GetArchSupport()) {
|
||||||
as->mouseDown(coord, button, mods);
|
// as->mouseDown(coord, button, mods);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
m_imguiCallback.mouseDown(coord, button, mods);
|
// m_imguiCallback.mouseDown(coord, button, mods);
|
||||||
}
|
}
|
||||||
|
|
||||||
void mouseUp(const boo::SWindowCoord& coord, boo::EMouseButton button, boo::EModifierKey mods) override {
|
void mouseUp(const boo::SWindowCoord& coord, boo::EMouseButton button, boo::EModifierKey mods) override {
|
||||||
|
@ -174,38 +178,38 @@ private:
|
||||||
as->mouseUp(coord, button, mods);
|
as->mouseUp(coord, button, mods);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_imguiCallback.mouseUp(coord, button, mods);
|
// m_imguiCallback.mouseUp(coord, button, mods);
|
||||||
}
|
}
|
||||||
|
|
||||||
void mouseMove(const boo::SWindowCoord& coord) override {
|
void mouseMove(const boo::SWindowCoord& coord) override {
|
||||||
if (!ImGuiWindowCallback::m_mouseCaptured && g_mainMP1) {
|
// if (!ImGuiWindowCallback::m_mouseCaptured && g_mainMP1) {
|
||||||
if (MP1::CGameArchitectureSupport* as = g_mainMP1->GetArchSupport()) {
|
// if (MP1::CGameArchitectureSupport* as = g_mainMP1->GetArchSupport()) {
|
||||||
as->mouseMove(coord);
|
// as->mouseMove(coord);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
m_imguiCallback.mouseMove(coord);
|
// m_imguiCallback.mouseMove(coord);
|
||||||
}
|
}
|
||||||
|
|
||||||
void mouseEnter(const boo::SWindowCoord& coord) override { m_imguiCallback.mouseEnter(coord); }
|
// void mouseEnter(const boo::SWindowCoord& coord) override { m_imguiCallback.mouseEnter(coord); }
|
||||||
|
|
||||||
void mouseLeave(const boo::SWindowCoord& coord) override { m_imguiCallback.mouseLeave(coord); }
|
// void mouseLeave(const boo::SWindowCoord& coord) override { m_imguiCallback.mouseLeave(coord); }
|
||||||
|
|
||||||
void scroll(const boo::SWindowCoord& coord, const boo::SScrollDelta& scroll) override {
|
void scroll(const boo::SWindowCoord& coord, const boo::SScrollDelta& scroll) override {
|
||||||
if (!ImGuiWindowCallback::m_mouseCaptured && g_mainMP1) {
|
// if (!ImGuiWindowCallback::m_mouseCaptured && g_mainMP1) {
|
||||||
if (MP1::CGameArchitectureSupport* as = g_mainMP1->GetArchSupport()) {
|
// if (MP1::CGameArchitectureSupport* as = g_mainMP1->GetArchSupport()) {
|
||||||
as->scroll(coord, scroll);
|
// as->scroll(coord, scroll);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
m_imguiCallback.scroll(coord, scroll);
|
// m_imguiCallback.scroll(coord, scroll);
|
||||||
}
|
}
|
||||||
|
|
||||||
void charKeyDown(unsigned long charCode, boo::EModifierKey mods, bool isRepeat) override {
|
void charKeyDown(unsigned long charCode, boo::EModifierKey mods, bool isRepeat) override {
|
||||||
if (!ImGuiWindowCallback::m_keyboardCaptured && g_mainMP1) {
|
// if (!ImGuiWindowCallback::m_keyboardCaptured && g_mainMP1) {
|
||||||
if (MP1::CGameArchitectureSupport* as = g_mainMP1->GetArchSupport()) {
|
// if (MP1::CGameArchitectureSupport* as = g_mainMP1->GetArchSupport()) {
|
||||||
as->charKeyDown(charCode, mods, isRepeat);
|
// as->charKeyDown(charCode, mods, isRepeat);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
m_imguiCallback.charKeyDown(charCode, mods, isRepeat);
|
// m_imguiCallback.charKeyDown(charCode, mods, isRepeat);
|
||||||
}
|
}
|
||||||
|
|
||||||
void charKeyUp(unsigned long charCode, boo::EModifierKey mods) override {
|
void charKeyUp(unsigned long charCode, boo::EModifierKey mods) override {
|
||||||
|
@ -214,40 +218,39 @@ private:
|
||||||
as->charKeyUp(charCode, mods);
|
as->charKeyUp(charCode, mods);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_imguiCallback.charKeyUp(charCode, mods);
|
// m_imguiCallback.charKeyUp(charCode, mods);
|
||||||
}
|
}
|
||||||
|
|
||||||
void specialKeyDown(boo::ESpecialKey key, boo::EModifierKey mods, bool isRepeat) override {
|
void specialKeyDown(boo::ESpecialKey key, boo::EModifierKey mods, bool isRepeat) override {
|
||||||
if (!ImGuiWindowCallback::m_keyboardCaptured && g_mainMP1) {
|
// if (!ImGuiWindowCallback::m_keyboardCaptured && g_mainMP1) {
|
||||||
if (MP1::CGameArchitectureSupport* as = g_mainMP1->GetArchSupport()) {
|
// if (MP1::CGameArchitectureSupport* as = g_mainMP1->GetArchSupport()) {
|
||||||
as->specialKeyDown(key, mods, isRepeat);
|
// as->specialKeyDown(key, mods, isRepeat);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
if (True(mods & boo::EModifierKey::Alt)) {
|
// if (True(mods & boo::EModifierKey::Alt)) {
|
||||||
if (key == boo::ESpecialKey::Enter) {
|
// if (key == boo::ESpecialKey::Enter) {
|
||||||
m_fullscreenToggleRequested = true;
|
// m_fullscreenToggleRequested = true;
|
||||||
} else if (key == boo::ESpecialKey::F4) {
|
// } else if (key == boo::ESpecialKey::F4) {
|
||||||
m_windowInvalid = true;
|
// m_windowInvalid = true;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
m_imguiCallback.specialKeyDown(key, mods, isRepeat);
|
// m_imguiCallback.specialKeyDown(key, mods, isRepeat);
|
||||||
}
|
}
|
||||||
|
|
||||||
void specialKeyUp(boo::ESpecialKey key, boo::EModifierKey mods) override {
|
void specialKeyUp(boo::ESpecialKey key, boo::EModifierKey mods) override {
|
||||||
if (g_mainMP1) {
|
// if (g_mainMP1) {
|
||||||
if (MP1::CGameArchitectureSupport* as = g_mainMP1->GetArchSupport()) {
|
// if (MP1::CGameArchitectureSupport* as = g_mainMP1->GetArchSupport()) {
|
||||||
as->specialKeyUp(key, mods);
|
// as->specialKeyUp(key, mods);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
m_imguiCallback.specialKeyUp(key, mods);
|
// m_imguiCallback.specialKeyUp(key, mods);
|
||||||
}
|
}
|
||||||
|
|
||||||
void destroyed() override { m_windowInvalid = true; }
|
void destroyed() override { m_windowInvalid = true; }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Application : boo::IApplicationCallback {
|
struct Application : aurora::AppDelegate {
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<boo::IWindow> m_window;
|
|
||||||
WindowCallback m_windowCallback;
|
WindowCallback m_windowCallback;
|
||||||
hecl::Runtime::FileStoreManager& m_fileMgr;
|
hecl::Runtime::FileStoreManager& m_fileMgr;
|
||||||
hecl::CVarManager& m_cvarManager;
|
hecl::CVarManager& m_cvarManager;
|
||||||
|
@ -255,17 +258,16 @@ private:
|
||||||
ImGuiConsole m_imGuiConsole;
|
ImGuiConsole m_imGuiConsole;
|
||||||
std::string m_errorString;
|
std::string m_errorString;
|
||||||
|
|
||||||
boo::ObjToken<boo::ITextureR> m_renderTex;
|
// boo::ObjToken<boo::ITextureR> m_renderTex;
|
||||||
std::string m_deferredProject;
|
std::string m_deferredProject;
|
||||||
std::unique_ptr<hecl::Database::Project> m_proj;
|
bool m_projectInitialized = false;
|
||||||
|
// std::unique_ptr<hecl::Database::Project> m_proj;
|
||||||
std::optional<amuse::BooBackendVoiceAllocator> m_amuseAllocWrapper;
|
std::optional<amuse::BooBackendVoiceAllocator> m_amuseAllocWrapper;
|
||||||
std::unique_ptr<boo::IAudioVoiceEngine> m_voiceEngine;
|
std::unique_ptr<boo::IAudioVoiceEngine> m_voiceEngine;
|
||||||
std::unique_ptr<hecl::PipelineConverterBase> m_pipelineConv;
|
// std::unique_ptr<hecl::PipelineConverterBase> m_pipelineConv;
|
||||||
|
|
||||||
Limiter m_limiter{};
|
Limiter m_limiter{};
|
||||||
std::atomic_bool m_running = {true};
|
|
||||||
bool m_noShaderWarmup = false;
|
bool m_noShaderWarmup = false;
|
||||||
bool m_imGuiInitialized = false;
|
|
||||||
|
|
||||||
bool m_firstFrame = true;
|
bool m_firstFrame = true;
|
||||||
using delta_clock = std::chrono::high_resolution_clock;
|
using delta_clock = std::chrono::high_resolution_clock;
|
||||||
|
@ -275,41 +277,25 @@ public:
|
||||||
Application(hecl::Runtime::FileStoreManager& fileMgr, hecl::CVarManager& cvarMgr, hecl::CVarCommons& cvarCmns)
|
Application(hecl::Runtime::FileStoreManager& fileMgr, hecl::CVarManager& cvarMgr, hecl::CVarCommons& cvarCmns)
|
||||||
: m_fileMgr(fileMgr), m_cvarManager(cvarMgr), m_cvarCommons(cvarCmns), m_imGuiConsole(cvarMgr, cvarCmns) {}
|
: m_fileMgr(fileMgr), m_cvarManager(cvarMgr), m_cvarCommons(cvarCmns), m_imGuiConsole(cvarMgr, cvarCmns) {}
|
||||||
|
|
||||||
int appMain(boo::IApplication* app) override {
|
void onAppLaunched() override {
|
||||||
initialize(app);
|
initialize();
|
||||||
|
|
||||||
m_window = app->newWindow("Metaforce"sv);
|
auto backend = static_cast<std::string>(aurora::get_backend_string());
|
||||||
if (!m_window) {
|
aurora::set_window_title(fmt::format(FMT_STRING("Metaforce {} [{}]"), METAFORCE_WC_DESCRIBE, backend));
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
m_window->setCallback(&m_windowCallback);
|
|
||||||
m_window->showWindow();
|
|
||||||
|
|
||||||
boo::IGraphicsDataFactory* gfxF = m_window->getMainContextDataFactory();
|
m_voiceEngine = boo::NewAudioVoiceEngine("metaforce", "Metaforce");
|
||||||
m_window->setTitle(fmt::format(FMT_STRING("Metaforce {} [{}]"), METAFORCE_WC_DESCRIBE, gfxF->platformName()));
|
|
||||||
|
|
||||||
boo::SWindowRect rect = m_window->getWindowFrame();
|
|
||||||
m_windowCallback.m_lastRect = rect;
|
|
||||||
gfxF->commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) {
|
|
||||||
m_renderTex = ctx.newRenderTexture(rect.size[0], rect.size[1], boo::TextureClampMode::ClampToEdge, 3, 3);
|
|
||||||
return true;
|
|
||||||
} BooTrace);
|
|
||||||
|
|
||||||
m_pipelineConv = hecl::NewPipelineConverter(gfxF);
|
|
||||||
hecl::conv = m_pipelineConv.get();
|
|
||||||
|
|
||||||
m_voiceEngine = boo::NewAudioVoiceEngine();
|
|
||||||
m_voiceEngine->setVolume(0.7f);
|
m_voiceEngine->setVolume(0.7f);
|
||||||
m_amuseAllocWrapper.emplace(*m_voiceEngine);
|
m_amuseAllocWrapper.emplace(*m_voiceEngine);
|
||||||
|
|
||||||
hecl::ProjectPath projectPath;
|
// hecl::ProjectPath projectPath;
|
||||||
for (const auto& arg : app->getArgs()) {
|
for (const auto& str : aurora::get_args()) {
|
||||||
hecl::Sstat theStat;
|
auto arg = static_cast<std::string>(str);
|
||||||
if (!hecl::Stat((arg + "/out").c_str(), &theStat) && S_ISDIR(theStat.st_mode)) {
|
// hecl::Sstat theStat;
|
||||||
hecl::ProjectRootPath rootPath(arg);
|
// if (hecl::Stat((arg + "/out").c_str(), &theStat) == 0 && S_ISDIR(theStat.st_mode)) {
|
||||||
hecl::Database::Project tmp(rootPath); // Force project creation
|
// hecl::ProjectRootPath rootPath(arg);
|
||||||
}
|
// hecl::Database::Project tmp(rootPath); // Force project creation
|
||||||
if (m_deferredProject.empty() && hecl::SearchForProject(arg))
|
// }
|
||||||
|
if (m_deferredProject.empty() && !arg.starts_with('-') && !arg.starts_with('+'))
|
||||||
m_deferredProject = arg;
|
m_deferredProject = arg;
|
||||||
if (arg == "--no-shader-warmup")
|
if (arg == "--no-shader-warmup")
|
||||||
m_noShaderWarmup = true;
|
m_noShaderWarmup = true;
|
||||||
|
@ -317,45 +303,23 @@ public:
|
||||||
m_voiceEngine->setVolume(0.f);
|
m_voiceEngine->setVolume(0.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_deferredProject.empty()) {
|
// if (m_deferredProject.empty()) {
|
||||||
/* Default behavior - search upwards for packaged project containing the program */
|
// /* Default behavior - search upwards for packaged project containing the program */
|
||||||
if (hecl::ProjectRootPath projRoot = hecl::SearchForProject(ExeDir)) {
|
// if (hecl::ProjectRootPath projRoot = hecl::SearchForProject(ExeDir)) {
|
||||||
std::string rootPath(projRoot.getAbsolutePath());
|
// std::string rootPath(projRoot.getAbsolutePath());
|
||||||
hecl::Sstat theStat;
|
// hecl::Sstat theStat;
|
||||||
if (hecl::Stat((rootPath + "/out/files/MP1/Metroid1.upak").c_str(), &theStat) == 0 && S_ISREG(theStat.st_mode))
|
// if (hecl::Stat((rootPath + "/out/files/MP1/Metroid1.upak").c_str(), &theStat) == 0 && S_ISREG(theStat.st_mode))
|
||||||
m_deferredProject = rootPath + "/out";
|
// m_deferredProject = rootPath + "/out";
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
while (m_running) {
|
|
||||||
onAppIdle();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_imGuiInitialized) {
|
|
||||||
m_imGuiConsole.Shutdown();
|
|
||||||
ImGuiEngine::Shutdown();
|
|
||||||
}
|
|
||||||
if (g_mainMP1) {
|
|
||||||
g_mainMP1->Shutdown();
|
|
||||||
}
|
|
||||||
g_mainMP1.reset();
|
|
||||||
m_renderTex.reset();
|
|
||||||
m_pipelineConv.reset();
|
|
||||||
if (m_window) {
|
|
||||||
m_window->getCommandQueue()->stopRenderer();
|
|
||||||
}
|
|
||||||
m_cvarManager.serialize();
|
|
||||||
m_voiceEngine.reset();
|
|
||||||
m_amuseAllocWrapper.reset();
|
|
||||||
CDvdFile::Shutdown();
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void initialize(boo::IApplication* app) {
|
void initialize() {
|
||||||
zeus::detectCPU();
|
zeus::detectCPU();
|
||||||
|
|
||||||
for (const auto& arg : app->getArgs()) {
|
for (const auto& str : aurora::get_args()) {
|
||||||
if (arg.find("--verbosity=") == 0 || arg.find("-v=") == 0) {
|
auto arg = static_cast<std::string>(str);
|
||||||
|
if (arg.starts_with("--verbosity=") || arg.starts_with("-v=")) {
|
||||||
hecl::VerbosityLevel = atoi(arg.substr(arg.find_last_of('=') + 1).c_str());
|
hecl::VerbosityLevel = atoi(arg.substr(arg.find_last_of('=') + 1).c_str());
|
||||||
hecl::LogModule.report(logvisor::Info, FMT_STRING("Set verbosity level to {}"), hecl::VerbosityLevel);
|
hecl::LogModule.report(logvisor::Info, FMT_STRING("Set verbosity level to {}"), hecl::VerbosityLevel);
|
||||||
}
|
}
|
||||||
|
@ -367,30 +331,20 @@ public:
|
||||||
Log.report(logvisor::Info, FMT_STRING("CPU Features: {}"), CPUFeatureString(cpuInf));
|
Log.report(logvisor::Info, FMT_STRING("CPU Features: {}"), CPUFeatureString(cpuInf));
|
||||||
}
|
}
|
||||||
|
|
||||||
void onAppIdle() noexcept {
|
bool onAppIdle(float realDt) noexcept override {
|
||||||
if (!m_deferredProject.empty()) {
|
if (!m_projectInitialized && !m_deferredProject.empty()) {
|
||||||
std::string subPath;
|
if (CDvdFile::Initialize(m_deferredProject)) {
|
||||||
hecl::ProjectRootPath projPath = hecl::SearchForProject(m_deferredProject, subPath);
|
m_projectInitialized = true;
|
||||||
if (projPath) {
|
|
||||||
m_proj = std::make_unique<hecl::Database::Project>(projPath);
|
|
||||||
m_deferredProject.clear();
|
|
||||||
hecl::ProjectPath projectPath{m_proj->getProjectWorkingPath(), "out/files/MP1"};
|
|
||||||
CDvdFile::Initialize(projectPath);
|
|
||||||
} else {
|
} else {
|
||||||
Log.report(logvisor::Error, FMT_STRING("Project doesn't exist at '{}'"), m_deferredProject);
|
Log.report(logvisor::Error, FMT_STRING("Project doesn't exist at '{}'"), m_deferredProject);
|
||||||
m_errorString = fmt::format(FMT_STRING("Project not found at '{}'"), m_deferredProject);
|
m_errorString = fmt::format(FMT_STRING("Project not found at '{}'"), m_deferredProject);
|
||||||
m_deferredProject.clear();
|
m_deferredProject.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!m_proj && m_errorString.empty()) {
|
if (!m_projectInitialized && m_errorString.empty()) {
|
||||||
m_errorString = "Project directory not specified"s;
|
m_errorString = "Project directory not specified"s;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_windowCallback.m_windowInvalid) {
|
|
||||||
m_running.store(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto targetFrameTime = getTargetFrameTime();
|
const auto targetFrameTime = getTargetFrameTime();
|
||||||
bool skipRetrace = false;
|
bool skipRetrace = false;
|
||||||
if (g_ResFactory != nullptr) {
|
if (g_ResFactory != nullptr) {
|
||||||
|
@ -404,10 +358,6 @@ public:
|
||||||
m_limiter.Reset();
|
m_limiter.Reset();
|
||||||
} else {
|
} else {
|
||||||
// No more to load, and we're under frame time
|
// No more to load, and we're under frame time
|
||||||
{
|
|
||||||
OPTICK_EVENT("Wait for Retrace");
|
|
||||||
m_window->waitForRetrace();
|
|
||||||
}
|
|
||||||
{
|
{
|
||||||
OPTICK_EVENT("Sleep");
|
OPTICK_EVENT("Sleep");
|
||||||
m_limiter.Sleep(targetFrameTime);
|
m_limiter.Sleep(targetFrameTime);
|
||||||
|
@ -415,18 +365,20 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
OPTICK_FRAME("MainThread");
|
OPTICK_FRAME("MainThread");
|
||||||
CGraphics::SetCommitResourcesAsLazy(m_cvarCommons.m_lazyCommitResources->toBoolean());
|
// CGraphics::SetCommitResourcesAsLazy(m_cvarCommons.m_lazyCommitResources->toBoolean());
|
||||||
|
|
||||||
boo::SWindowRect rect = m_windowCallback.m_lastRect;
|
// TODO
|
||||||
rect.location = {0, 0};
|
// boo::SWindowRect rect = m_windowCallback.m_lastRect;
|
||||||
boo::IGraphicsCommandQueue* gfxQ = m_window->getCommandQueue();
|
// rect.location = {0, 0};
|
||||||
if (m_windowCallback.m_rectDirty) {
|
// boo::IGraphicsCommandQueue* gfxQ = m_window->getCommandQueue();
|
||||||
gfxQ->resizeRenderTexture(m_renderTex, rect.size[0], rect.size[1]);
|
// if (m_windowCallback.m_rectDirty) {
|
||||||
CGraphics::SetViewportResolution({rect.size[0], rect.size[1]});
|
// gfxQ->resizeRenderTexture(m_renderTex, rect.size[0], rect.size[1]);
|
||||||
m_windowCallback.m_rectDirty = false;
|
// CGraphics::SetViewportResolution({rect.size[0], rect.size[1]});
|
||||||
} else if (m_firstFrame) {
|
// m_windowCallback.m_rectDirty = false;
|
||||||
CGraphics::SetViewportResolution({rect.size[0], rect.size[1]});
|
// } else if (m_firstFrame) {
|
||||||
}
|
auto rect = aurora::get_window_size();
|
||||||
|
CGraphics::SetViewportResolution({static_cast<int32_t>(rect.width), static_cast<int32_t>(rect.height)});
|
||||||
|
// }
|
||||||
|
|
||||||
// Check if fullscreen has been toggled, if so set the fullscreen cvar accordingly
|
// Check if fullscreen has been toggled, if so set the fullscreen cvar accordingly
|
||||||
if (m_windowCallback.m_fullscreenToggleRequested) {
|
if (m_windowCallback.m_fullscreenToggleRequested) {
|
||||||
|
@ -436,88 +388,63 @@ public:
|
||||||
|
|
||||||
// Check if the user has modified the fullscreen CVar, if so set fullscreen state accordingly
|
// Check if the user has modified the fullscreen CVar, if so set fullscreen state accordingly
|
||||||
if (m_cvarCommons.m_fullscreen->isModified()) {
|
if (m_cvarCommons.m_fullscreen->isModified()) {
|
||||||
m_window->setFullscreen(m_cvarCommons.getFullscreen());
|
aurora::set_fullscreen(m_cvarCommons.getFullscreen());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Let CVarManager inform all CVar listeners of the CVar's state and clear all mdoified flags if necessary
|
// Let CVarManager inform all CVar listeners of the CVar's state and clear all mdoified flags if necessary
|
||||||
m_cvarManager.proc();
|
m_cvarManager.proc();
|
||||||
|
|
||||||
boo::IGraphicsDataFactory* gfxF = m_window->getMainContextDataFactory();
|
// TODO
|
||||||
float scale = std::floor(m_window->getVirtualPixelFactor() * 4.f) / 4.f;
|
// boo::IGraphicsDataFactory* gfxF = m_window->getMainContextDataFactory();
|
||||||
if (!g_mainMP1 && m_proj) {
|
// float scale = std::floor(m_window->getVirtualPixelFactor() * 4.f) / 4.f;
|
||||||
g_mainMP1.emplace(nullptr, nullptr, gfxF, gfxQ, m_renderTex.get());
|
if (!g_mainMP1 && m_projectInitialized) {
|
||||||
g_mainMP1->Init(m_fileMgr, &m_cvarManager, m_window.get(), m_voiceEngine.get(), *m_amuseAllocWrapper);
|
g_mainMP1.emplace(nullptr, nullptr);
|
||||||
|
g_mainMP1->Init(m_fileMgr, &m_cvarManager, m_voiceEngine.get(), *m_amuseAllocWrapper);
|
||||||
if (!m_noShaderWarmup) {
|
if (!m_noShaderWarmup) {
|
||||||
g_mainMP1->WarmupShaders();
|
g_mainMP1->WarmupShaders();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!m_imGuiInitialized) {
|
// if (!m_imGuiInitialized) {
|
||||||
ImGuiEngine::Initialize(gfxF, m_window.get(), scale, m_fileMgr.getStoreRoot());
|
// ImGuiEngine::Initialize(gfxF, m_window.get(), scale, m_fileMgr.getStoreRoot());
|
||||||
m_imGuiInitialized = true;
|
// m_imGuiInitialized = true;
|
||||||
}
|
// }
|
||||||
|
|
||||||
float dt = 1 / 60.f;
|
float dt = 1 / 60.f;
|
||||||
float realDt = dt;
|
if (m_cvarCommons.m_variableDt->toBoolean()) {
|
||||||
auto now = delta_clock::now();
|
dt = std::min(realDt, 1 / 30.f);
|
||||||
if (m_firstFrame) {
|
|
||||||
m_firstFrame = false;
|
|
||||||
} else {
|
|
||||||
using delta_duration = std::chrono::duration<float, std::ratio<1>>;
|
|
||||||
realDt = std::chrono::duration_cast<delta_duration>(now - m_prevFrameTime).count();
|
|
||||||
if (m_cvarCommons.m_variableDt->toBoolean()) {
|
|
||||||
dt = std::min(realDt, 1 / 30.f);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
m_prevFrameTime = now;
|
|
||||||
|
|
||||||
ImGuiEngine::Begin(realDt, scale);
|
|
||||||
|
|
||||||
if (g_mainMP1) {
|
if (g_mainMP1) {
|
||||||
m_imGuiConsole.PreUpdate();
|
m_imGuiConsole.PreUpdate();
|
||||||
if (g_mainMP1->Proc(dt)) {
|
if (g_mainMP1->Proc(dt)) {
|
||||||
m_running.store(false);
|
return false;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
m_imGuiConsole.PostUpdate();
|
m_imGuiConsole.PostUpdate();
|
||||||
} else {
|
} else {
|
||||||
m_imGuiConsole.ShowAboutWindow(false, m_errorString);
|
m_imGuiConsole.ShowAboutWindow(false, m_errorString);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
// {
|
||||||
OPTICK_EVENT("Flush");
|
// OPTICK_EVENT("Flush");
|
||||||
CGraphics::SetCommitResourcesAsLazy(false);
|
// CGraphics::SetCommitResourcesAsLazy(false);
|
||||||
}
|
// }
|
||||||
|
|
||||||
{
|
return true;
|
||||||
OPTICK_EVENT("Draw");
|
}
|
||||||
gfxQ->setRenderTarget(m_renderTex);
|
|
||||||
gfxQ->clearTarget();
|
void onAppDraw() noexcept override {
|
||||||
gfxQ->setViewport(rect);
|
OPTICK_EVENT("Draw");
|
||||||
gfxQ->setScissor(rect);
|
if (g_Renderer != nullptr) {
|
||||||
if (g_Renderer != nullptr) {
|
g_Renderer->BeginScene();
|
||||||
g_Renderer->BeginScene();
|
|
||||||
}
|
|
||||||
if (g_mainMP1) {
|
if (g_mainMP1) {
|
||||||
g_mainMP1->Draw();
|
g_mainMP1->Draw();
|
||||||
}
|
}
|
||||||
if (g_Renderer != nullptr) {
|
g_Renderer->EndScene();
|
||||||
g_Renderer->EndScene();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
{
|
void onAppPostDraw() noexcept override {
|
||||||
OPTICK_EVENT("ImGui Draw");
|
OPTICK_EVENT("PostDraw");
|
||||||
ImGuiEngine::End();
|
|
||||||
ImGuiEngine::Draw(gfxQ);
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
OPTICK_EVENT("Execute");
|
|
||||||
gfxQ->execute();
|
|
||||||
}
|
|
||||||
|
|
||||||
gfxQ->resolveDisplay(m_renderTex);
|
|
||||||
|
|
||||||
if (m_voiceEngine) {
|
if (m_voiceEngine) {
|
||||||
m_voiceEngine->pumpAndMixVoices();
|
m_voiceEngine->pumpAndMixVoices();
|
||||||
}
|
}
|
||||||
|
@ -526,7 +453,19 @@ public:
|
||||||
++logvisor::FrameIndex;
|
++logvisor::FrameIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
void appQuitting(boo::IApplication* /*unused*/) override { m_running.store(false); }
|
void onAppExiting() noexcept override {
|
||||||
|
m_imGuiConsole.Shutdown();
|
||||||
|
if (g_mainMP1) {
|
||||||
|
g_mainMP1->Shutdown();
|
||||||
|
}
|
||||||
|
g_mainMP1.reset();
|
||||||
|
// m_renderTex.reset();
|
||||||
|
// m_pipelineConv.reset();
|
||||||
|
m_cvarManager.serialize();
|
||||||
|
m_voiceEngine.reset();
|
||||||
|
m_amuseAllocWrapper.reset();
|
||||||
|
CDvdFile::Shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
[[nodiscard]] std::string getGraphicsApi() const { return m_cvarCommons.getGraphicsApi(); }
|
[[nodiscard]] std::string getGraphicsApi() const { return m_cvarCommons.getGraphicsApi(); }
|
||||||
|
|
||||||
|
@ -626,11 +565,9 @@ int main(int argc, char** argv) {
|
||||||
/* Handle -j argument */
|
/* Handle -j argument */
|
||||||
hecl::SetCpuCountOverride(argc, argv);
|
hecl::SetCpuCountOverride(argc, argv);
|
||||||
|
|
||||||
metaforce::Application appCb(fileMgr, cvarMgr, cvarCmns);
|
auto app = std::make_unique<metaforce::Application>(fileMgr, cvarMgr, cvarCmns);
|
||||||
int ret = boo::ApplicationRun(boo::IApplication::EPlatformType::Auto, appCb, "metaforce", "Metaforce", argv[0], args,
|
aurora::app_run(std::move(app));
|
||||||
appCb.getGraphicsApi(), appCb.getSamples(), appCb.getAnisotropy(), appCb.getDeepColor(),
|
return 0;
|
||||||
false);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -136,7 +136,7 @@ endfunction()
|
||||||
|
|
||||||
set(RUNTIME_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
|
set(RUNTIME_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
set(RUNTIME_LIBRARIES ${HECL_APPLICATION_REPS_TARGETS_LIST} RetroDataSpec AssetNameMapNull NESEmulator
|
set(RUNTIME_LIBRARIES ${HECL_APPLICATION_REPS_TARGETS_LIST} RetroDataSpec AssetNameMapNull NESEmulator
|
||||||
libjpeg-turbo jbus kabufuda discord-rpc logvisor OptickCore imgui)
|
libjpeg-turbo jbus kabufuda discord-rpc logvisor OptickCore imgui aurora)
|
||||||
|
|
||||||
add_runtime_common_library(RuntimeCommon ${RUNTIME_SOURCES_A})
|
add_runtime_common_library(RuntimeCommon ${RUNTIME_SOURCES_A})
|
||||||
target_include_directories(RuntimeCommon PUBLIC ${RUNTIME_INCLUDES})
|
target_include_directories(RuntimeCommon PUBLIC ${RUNTIME_INCLUDES})
|
||||||
|
@ -205,7 +205,7 @@ elseif (UNIX)
|
||||||
set(PLAT_LIBS rt)
|
set(PLAT_LIBS rt)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
add_executable(metaforce CMain.cpp ${PLAT_SRCS} ImGuiConsole.hpp ImGuiConsole.cpp ImGuiEntitySupport.hpp ImGuiEntitySupport.cpp) # ImGuiPlayerLoadouts.hpp
|
add_executable(metaforce CMain.cpp ${PLAT_SRCS} ImGuiConsole.hpp ImGuiConsole.cpp ImGuiEntitySupport.hpp ImGuiEntitySupport.cpp ../Graphics/lib.cpp) # ImGuiPlayerLoadouts.hpp
|
||||||
# target_atdna(metaforce atdna_ImGuiPlayerLoadouts.cpp ImGuiPlayerLoadouts.hpp)
|
# target_atdna(metaforce atdna_ImGuiPlayerLoadouts.cpp ImGuiPlayerLoadouts.hpp)
|
||||||
# RUNTIME_LIBRARIES repeated here for link ordering
|
# RUNTIME_LIBRARIES repeated here for link ordering
|
||||||
target_link_libraries(metaforce PUBLIC RuntimeCommon RuntimeCommonB ${RUNTIME_LIBRARIES} ${PLAT_LIBS})
|
target_link_libraries(metaforce PUBLIC RuntimeCommon RuntimeCommonB ${RUNTIME_LIBRARIES} ${PLAT_LIBS})
|
||||||
|
@ -215,7 +215,7 @@ if (COMMAND add_sanitizers)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
if (NOT WINDOWS_STORE)
|
if (NOT WINDOWS_STORE)
|
||||||
add_dependencies(metaforce visigen hecl)
|
add_dependencies(metaforce hecl) # visigen
|
||||||
else ()
|
else ()
|
||||||
set_property(TARGET metaforce PROPERTY VS_WINRT_COMPONENT TRUE)
|
set_property(TARGET metaforce PROPERTY VS_WINRT_COMPONENT TRUE)
|
||||||
# This should match the Package.appxmanifest
|
# This should match the Package.appxmanifest
|
||||||
|
|
|
@ -63,10 +63,10 @@ void CPakFile::InitialHeaderLoad() {
|
||||||
athena::io::MemoryReader r(x38_headerData.data(), x38_headerData.size());
|
athena::io::MemoryReader r(x38_headerData.data(), x38_headerData.size());
|
||||||
x30_dvdReq.reset();
|
x30_dvdReq.reset();
|
||||||
u32 version = r.readUint32Big();
|
u32 version = r.readUint32Big();
|
||||||
if (version != 0x80030005) {
|
if (version != 0x00030005) {
|
||||||
Log.report(logvisor::Fatal,
|
Log.report(logvisor::Fatal,
|
||||||
FMT_STRING("{}: Incompatible pak file version -- Current version is {:08X}, you're using {:08X}"),
|
FMT_STRING("{}: Incompatible pak file version -- Current version is {:08X}, you're using {:08X}"),
|
||||||
GetPath(), 0x80030005, version);
|
GetPath(), 0x00030005, version);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ static logvisor::Module Log("CResLoader");
|
||||||
CResLoader::CResLoader() { x48_curPak = x18_pakLoadedList.end(); }
|
CResLoader::CResLoader() { x48_curPak = x18_pakLoadedList.end(); }
|
||||||
|
|
||||||
const std::vector<CAssetId>* CResLoader::GetTagListForFile(std::string_view name) const {
|
const std::vector<CAssetId>* CResLoader::GetTagListForFile(std::string_view name) const {
|
||||||
const std::string namePak = std::string(name).append(".upak");
|
const std::string namePak = std::string(name).append(".pak");
|
||||||
for (const std::unique_ptr<CPakFile>& pak : x18_pakLoadedList) {
|
for (const std::unique_ptr<CPakFile>& pak : x18_pakLoadedList) {
|
||||||
if (CStringExtras::CompareCaseInsensitive(namePak, pak->x18_path)) {
|
if (CStringExtras::CompareCaseInsensitive(namePak, pak->x18_path)) {
|
||||||
return &pak->GetDepList();
|
return &pak->GetDepList();
|
||||||
|
@ -18,7 +18,7 @@ const std::vector<CAssetId>* CResLoader::GetTagListForFile(std::string_view name
|
||||||
}
|
}
|
||||||
|
|
||||||
void CResLoader::AddPakFileAsync(std::string_view name, bool buildDepList, bool worldPak, bool override) {
|
void CResLoader::AddPakFileAsync(std::string_view name, bool buildDepList, bool worldPak, bool override) {
|
||||||
const std::string namePak = std::string(name).append(".upak");
|
const std::string namePak = std::string(name).append(".pak");
|
||||||
if (CDvdFile::FileExists(namePak)) {
|
if (CDvdFile::FileExists(namePak)) {
|
||||||
x30_pakLoadingList.emplace_back(std::make_unique<CPakFile>(namePak, buildDepList, worldPak, override));
|
x30_pakLoadingList.emplace_back(std::make_unique<CPakFile>(namePak, buildDepList, worldPak, override));
|
||||||
++x44_pakLoadingCount;
|
++x44_pakLoadingCount;
|
||||||
|
@ -116,7 +116,7 @@ std::unique_ptr<u8[]> CResLoader::LoadNewResourcePartSync(const metaforce::SObje
|
||||||
}
|
}
|
||||||
|
|
||||||
void CResLoader::GetTagListForFile(const char* pakName, std::vector<SObjectTag>& out) const {
|
void CResLoader::GetTagListForFile(const char* pakName, std::vector<SObjectTag>& out) const {
|
||||||
std::string path = std::string(pakName) + ".upak";
|
std::string path = std::string(pakName) + ".pak";
|
||||||
|
|
||||||
for (const std::unique_ptr<CPakFile>& file : m_overridePakList) {
|
for (const std::unique_ptr<CPakFile>& file : m_overridePakList) {
|
||||||
if (_GetTagListForFile(out, path, file))
|
if (_GetTagListForFile(out, path, file))
|
||||||
|
|
|
@ -985,90 +985,90 @@ void CStateManager::DrawWorld() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CStateManager::DrawActorCubeFaces(CActor& actor, int& cubeInst) const {
|
void CStateManager::DrawActorCubeFaces(CActor& actor, int& cubeInst) const {
|
||||||
if (!actor.m_reflectionCube ||
|
// if (!actor.m_reflectionCube ||
|
||||||
(!TCastToPtr<CPlayer>(actor) && (!actor.GetActive() || !actor.IsDrawEnabled() || actor.xe4_30_outOfFrustum)))
|
// (!TCastToPtr<CPlayer>(actor) && (!actor.GetActive() || !actor.IsDrawEnabled() || actor.xe4_30_outOfFrustum)))
|
||||||
return;
|
// return;
|
||||||
|
//
|
||||||
const TAreaId visAreaId = actor.GetAreaIdAlways();
|
// const TAreaId visAreaId = actor.GetAreaIdAlways();
|
||||||
const SViewport backupVp = g_Viewport;
|
// const SViewport backupVp = g_Viewport;
|
||||||
|
//
|
||||||
int areaCount = 0;
|
// int areaCount = 0;
|
||||||
std::array<const CGameArea*, 10> areaArr;
|
// std::array<const CGameArea*, 10> areaArr;
|
||||||
for (const CGameArea& area : *x850_world) {
|
// for (const CGameArea& area : *x850_world) {
|
||||||
if (areaCount == 10) {
|
// if (areaCount == 10) {
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
auto occState = CGameArea::EOcclusionState::Occluded;
|
// auto occState = CGameArea::EOcclusionState::Occluded;
|
||||||
if (area.IsPostConstructed()) {
|
// if (area.IsPostConstructed()) {
|
||||||
occState = area.GetOcclusionState();
|
// occState = area.GetOcclusionState();
|
||||||
}
|
// }
|
||||||
if (occState == CGameArea::EOcclusionState::Visible) {
|
// if (occState == CGameArea::EOcclusionState::Visible) {
|
||||||
areaArr[areaCount++] = &area;
|
// areaArr[areaCount++] = &area;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
for (int f = 0; f < 6; ++f) {
|
// for (int f = 0; f < 6; ++f) {
|
||||||
SCOPED_GRAPHICS_DEBUG_GROUP(fmt::format(FMT_STRING("CStateManager::DrawActorCubeFaces [{}] {} {} {}"), f,
|
// SCOPED_GRAPHICS_DEBUG_GROUP(fmt::format(FMT_STRING("CStateManager::DrawActorCubeFaces [{}] {} {} {}"), f,
|
||||||
actor.GetUniqueId(), actor.GetEditorId(), actor.GetName())
|
// actor.GetUniqueId(), actor.GetEditorId(), actor.GetName())
|
||||||
.c_str(),
|
// .c_str(),
|
||||||
zeus::skOrange);
|
// zeus::skOrange);
|
||||||
CGraphics::g_BooMainCommandQueue->setRenderTarget(actor.m_reflectionCube, f);
|
// CGraphics::g_BooMainCommandQueue->setRenderTarget(actor.m_reflectionCube, f);
|
||||||
SetupViewForCubeFaceDraw(actor.GetRenderBounds().center(), f);
|
// SetupViewForCubeFaceDraw(actor.GetRenderBounds().center(), f);
|
||||||
CGraphics::g_BooMainCommandQueue->clearTarget();
|
// CGraphics::g_BooMainCommandQueue->clearTarget();
|
||||||
|
//
|
||||||
std::sort(areaArr.begin(), areaArr.begin() + areaCount, [visAreaId](const CGameArea* a, const CGameArea* b) {
|
// std::sort(areaArr.begin(), areaArr.begin() + areaCount, [visAreaId](const CGameArea* a, const CGameArea* b) {
|
||||||
if (a->x4_selfIdx == b->x4_selfIdx) {
|
// if (a->x4_selfIdx == b->x4_selfIdx) {
|
||||||
return false;
|
// return false;
|
||||||
}
|
// }
|
||||||
if (visAreaId == a->x4_selfIdx) {
|
// if (visAreaId == a->x4_selfIdx) {
|
||||||
return false;
|
// return false;
|
||||||
}
|
// }
|
||||||
if (visAreaId == b->x4_selfIdx) {
|
// if (visAreaId == b->x4_selfIdx) {
|
||||||
return true;
|
// return true;
|
||||||
}
|
// }
|
||||||
return CGraphics::g_ViewPoint.dot(a->GetAABB().center()) > CGraphics::g_ViewPoint.dot(b->GetAABB().center());
|
// return CGraphics::g_ViewPoint.dot(a->GetAABB().center()) > CGraphics::g_ViewPoint.dot(b->GetAABB().center());
|
||||||
});
|
// });
|
||||||
|
//
|
||||||
int pvsCount = 0;
|
// int pvsCount = 0;
|
||||||
std::array<CPVSVisSet, 10> pvsArr;
|
// std::array<CPVSVisSet, 10> pvsArr;
|
||||||
for (auto area = areaArr.cbegin(); area != areaArr.cbegin() + areaCount; ++area) {
|
// for (auto area = areaArr.cbegin(); area != areaArr.cbegin() + areaCount; ++area) {
|
||||||
const CGameArea* areaPtr = *area;
|
// const CGameArea* areaPtr = *area;
|
||||||
CPVSVisSet& pvsSet = pvsArr[pvsCount++];
|
// CPVSVisSet& pvsSet = pvsArr[pvsCount++];
|
||||||
pvsSet.Reset(EPVSVisSetState::OutOfBounds);
|
// pvsSet.Reset(EPVSVisSetState::OutOfBounds);
|
||||||
GetVisSetForArea(areaPtr->x4_selfIdx, visAreaId, pvsSet);
|
// GetVisSetForArea(areaPtr->x4_selfIdx, visAreaId, pvsSet);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
for (int i = areaCount - 1; i >= 0; --i) {
|
// for (int i = areaCount - 1; i >= 0; --i) {
|
||||||
const CGameArea& area = *areaArr[i];
|
// const CGameArea& area = *areaArr[i];
|
||||||
SetupFogForArea(area);
|
// SetupFogForArea(area);
|
||||||
g_Renderer->EnablePVS(pvsArr[i], area.x4_selfIdx);
|
// g_Renderer->EnablePVS(pvsArr[i], area.x4_selfIdx);
|
||||||
g_Renderer->SetWorldLightFadeLevel(area.GetPostConstructed()->x1128_worldLightingLevel);
|
// g_Renderer->SetWorldLightFadeLevel(area.GetPostConstructed()->x1128_worldLightingLevel);
|
||||||
g_Renderer->UpdateAreaUniforms(area.x4_selfIdx, EWorldShadowMode::None, true, cubeInst * 6 + f);
|
// g_Renderer->UpdateAreaUniforms(area.x4_selfIdx, EWorldShadowMode::None, true, cubeInst * 6 + f);
|
||||||
g_Renderer->DrawUnsortedGeometry(area.x4_selfIdx, 0x2, 0x0);
|
// g_Renderer->DrawUnsortedGeometry(area.x4_selfIdx, 0x2, 0x0);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (!SetupFogForDraw()) {
|
// if (!SetupFogForDraw()) {
|
||||||
g_Renderer->SetWorldFog(ERglFogMode::None, 0.f, 1.f, zeus::skBlack);
|
// g_Renderer->SetWorldFog(ERglFogMode::None, 0.f, 1.f, zeus::skBlack);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
x850_world->DrawSky(zeus::CTransform::Translate(CGraphics::g_ViewPoint));
|
// x850_world->DrawSky(zeus::CTransform::Translate(CGraphics::g_ViewPoint));
|
||||||
|
//
|
||||||
for (int i = 0; i < areaCount; ++i) {
|
// for (int i = 0; i < areaCount; ++i) {
|
||||||
const CGameArea& area = *areaArr[i];
|
// const CGameArea& area = *areaArr[i];
|
||||||
CPVSVisSet& pvs = pvsArr[i];
|
// CPVSVisSet& pvs = pvsArr[i];
|
||||||
SetupFogForArea(area);
|
// SetupFogForArea(area);
|
||||||
g_Renderer->SetWorldLightFadeLevel(area.GetPostConstructed()->x1128_worldLightingLevel);
|
// g_Renderer->SetWorldLightFadeLevel(area.GetPostConstructed()->x1128_worldLightingLevel);
|
||||||
g_Renderer->EnablePVS(pvs, area.x4_selfIdx);
|
// g_Renderer->EnablePVS(pvs, area.x4_selfIdx);
|
||||||
g_Renderer->DrawSortedGeometry(area.x4_selfIdx, 0x2, 0x0);
|
// g_Renderer->DrawSortedGeometry(area.x4_selfIdx, 0x2, 0x0);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
CGraphics::g_BooMainCommandQueue->generateMipmaps(actor.m_reflectionCube);
|
// CGraphics::g_BooMainCommandQueue->generateMipmaps(actor.m_reflectionCube);
|
||||||
|
//
|
||||||
CBooRenderer::BindMainDrawTarget();
|
// CBooRenderer::BindMainDrawTarget();
|
||||||
g_Renderer->SetViewport(backupVp.x0_left, backupVp.x4_top, backupVp.x8_width, backupVp.xc_height);
|
// g_Renderer->SetViewport(backupVp.x0_left, backupVp.x4_top, backupVp.x8_width, backupVp.xc_height);
|
||||||
|
//
|
||||||
++cubeInst;
|
// ++cubeInst;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CStateManager::DrawWorldCubeFaces() const {
|
void CStateManager::DrawWorldCubeFaces() const {
|
||||||
|
|
|
@ -23,4 +23,4 @@ CFactoryFnReturn FTextureCacheFactory([[maybe_unused]] const SObjectTag& tag, CI
|
||||||
[[maybe_unused]] CObjectReference* selfRef) {
|
[[maybe_unused]] CObjectReference* selfRef) {
|
||||||
return TToken<CTextureCache>::GetIObjObjectFor(std::make_unique<CTextureCache>(in));
|
return TToken<CTextureCache>::GetIObjObjectFor(std::make_unique<CTextureCache>(in));
|
||||||
}
|
}
|
||||||
} // namespace metaforce
|
} // namespace metaforce
|
||||||
|
|
|
@ -43,4 +43,4 @@ public:
|
||||||
|
|
||||||
CFactoryFnReturn FTextureCacheFactory(const metaforce::SObjectTag& tag, CInputStream& in,
|
CFactoryFnReturn FTextureCacheFactory(const metaforce::SObjectTag& tag, CInputStream& in,
|
||||||
const metaforce::CVParamTransfer& vparms, CObjectReference* selfRef);
|
const metaforce::CVParamTransfer& vparms, CObjectReference* selfRef);
|
||||||
} // namespace metaforce
|
} // namespace metaforce
|
||||||
|
|
|
@ -43,8 +43,7 @@ CAnimData::CAnimData(CAssetId id, const CCharacterInfo& character, int defaultAn
|
||||||
TLockedToken<CCharLayoutInfo> layout, TToken<CSkinnedModel> model,
|
TLockedToken<CCharLayoutInfo> layout, TToken<CSkinnedModel> model,
|
||||||
const std::optional<TToken<CMorphableSkinnedModel>>& iceModel,
|
const std::optional<TToken<CMorphableSkinnedModel>>& iceModel,
|
||||||
const std::weak_ptr<CAnimSysContext>& ctx, std::shared_ptr<CAnimationManager> animMgr,
|
const std::weak_ptr<CAnimSysContext>& ctx, std::shared_ptr<CAnimationManager> animMgr,
|
||||||
std::shared_ptr<CTransitionManager> transMgr, TLockedToken<CCharacterFactory> charFactory,
|
std::shared_ptr<CTransitionManager> transMgr, TLockedToken<CCharacterFactory> charFactory)
|
||||||
int drawInstCount)
|
|
||||||
: x0_charFactory(charFactory)
|
: x0_charFactory(charFactory)
|
||||||
, xc_charInfo(character)
|
, xc_charInfo(character)
|
||||||
, xcc_layoutData(layout)
|
, xcc_layoutData(layout)
|
||||||
|
@ -56,8 +55,7 @@ CAnimData::CAnimData(CAssetId id, const CCharacterInfo& character, int defaultAn
|
||||||
, x204_charIdx(charIdx)
|
, x204_charIdx(charIdx)
|
||||||
, x208_defaultAnim(defaultAnim)
|
, x208_defaultAnim(defaultAnim)
|
||||||
, x224_pose(layout->GetSegIdList().GetList().size())
|
, x224_pose(layout->GetSegIdList().GetList().size())
|
||||||
, x2fc_poseBuilder(CLayoutDescription{layout})
|
, x2fc_poseBuilder(CLayoutDescription{layout}) {
|
||||||
, m_drawInstCount(drawInstCount) {
|
|
||||||
x220_25_loop = loop;
|
x220_25_loop = loop;
|
||||||
|
|
||||||
if (iceModel)
|
if (iceModel)
|
||||||
|
@ -797,12 +795,11 @@ void CAnimData::AdvanceAnim(CCharAnimTime& time, zeus::CVector3f& offset, zeus::
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAnimData::SetXRayModel(const TLockedToken<CModel>& model, const TLockedToken<CSkinRules>& skinRules) {
|
void CAnimData::SetXRayModel(const TLockedToken<CModel>& model, const TLockedToken<CSkinRules>& skinRules) {
|
||||||
xf4_xrayModel = std::make_shared<CSkinnedModel>(model, skinRules, xd8_modelData->GetLayoutInfo(), 0, m_drawInstCount);
|
xf4_xrayModel = std::make_shared<CSkinnedModel>(model, skinRules, xd8_modelData->GetLayoutInfo(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAnimData::SetInfraModel(const TLockedToken<CModel>& model, const TLockedToken<CSkinRules>& skinRules) {
|
void CAnimData::SetInfraModel(const TLockedToken<CModel>& model, const TLockedToken<CSkinRules>& skinRules) {
|
||||||
xf8_infraModel =
|
xf8_infraModel = std::make_shared<CSkinnedModel>(model, skinRules, xd8_modelData->GetLayoutInfo(), 0);
|
||||||
std::make_shared<CSkinnedModel>(model, skinRules, xd8_modelData->GetLayoutInfo(), 0, m_drawInstCount);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAnimData::PoseSkinnedModel(CSkinnedModel& model, const CPoseAsTransforms& pose, const CModelFlags& drawFlags,
|
void CAnimData::PoseSkinnedModel(CSkinnedModel& model, const CPoseAsTransforms& pose, const CModelFlags& drawFlags,
|
||||||
|
|
|
@ -144,14 +144,12 @@ private:
|
||||||
static rstl::reserved_vector<CSoundPOINode, 20> g_SoundPOINodes;
|
static rstl::reserved_vector<CSoundPOINode, 20> g_SoundPOINodes;
|
||||||
static rstl::reserved_vector<CInt32POINode, 16> g_TransientInt32POINodes;
|
static rstl::reserved_vector<CInt32POINode, 16> g_TransientInt32POINodes;
|
||||||
|
|
||||||
int m_drawInstCount;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CAnimData(CAssetId, const CCharacterInfo& character, int defaultAnim, int charIdx, bool loop,
|
CAnimData(CAssetId, const CCharacterInfo& character, int defaultAnim, int charIdx, bool loop,
|
||||||
TLockedToken<CCharLayoutInfo> layout, TToken<CSkinnedModel> model,
|
TLockedToken<CCharLayoutInfo> layout, TToken<CSkinnedModel> model,
|
||||||
const std::optional<TToken<CMorphableSkinnedModel>>& iceModel, const std::weak_ptr<CAnimSysContext>& ctx,
|
const std::optional<TToken<CMorphableSkinnedModel>>& iceModel, const std::weak_ptr<CAnimSysContext>& ctx,
|
||||||
std::shared_ptr<CAnimationManager> animMgr, std::shared_ptr<CTransitionManager> transMgr,
|
std::shared_ptr<CAnimationManager> animMgr, std::shared_ptr<CTransitionManager> transMgr,
|
||||||
TLockedToken<CCharacterFactory> charFactory, int drawInstCount);
|
TLockedToken<CCharacterFactory> charFactory);
|
||||||
|
|
||||||
void SetParticleEffectState(std::string_view effectName, bool active, CStateManager& mgr);
|
void SetParticleEffectState(std::string_view effectName, bool active, CStateManager& mgr);
|
||||||
void InitializeEffects(CStateManager& mgr, TAreaId aId, const zeus::CVector3f& scale);
|
void InitializeEffects(CStateManager& mgr, TAreaId aId, const zeus::CVector3f& scale);
|
||||||
|
|
|
@ -24,13 +24,11 @@ CFactoryFnReturn CCharacterFactory::CDummyFactory::Build(const SObjectTag& tag,
|
||||||
|
|
||||||
switch (tag.type.toUint32() & 0x1) {
|
switch (tag.type.toUint32() & 0x1) {
|
||||||
case 0:
|
case 0:
|
||||||
return TToken<CSkinnedModel>::GetIObjObjectFor(
|
return TToken<CSkinnedModel>::GetIObjObjectFor(std::make_unique<CSkinnedModel>(
|
||||||
std::make_unique<CSkinnedModel>(*g_SimplePool, charInfo.GetModelId(), charInfo.GetSkinRulesId(),
|
*g_SimplePool, charInfo.GetModelId(), charInfo.GetSkinRulesId(), charInfo.GetCharLayoutInfoId(), 0));
|
||||||
charInfo.GetCharLayoutInfoId(), 0, tag.type.toUint32() >> 16));
|
|
||||||
case 1:
|
case 1:
|
||||||
return TToken<CSkinnedModel>::GetIObjObjectFor(
|
return TToken<CSkinnedModel>::GetIObjObjectFor(std::make_unique<CMorphableSkinnedModel>(
|
||||||
std::make_unique<CMorphableSkinnedModel>(*g_SimplePool, charInfo.GetIceModelId(), charInfo.GetIceSkinRulesId(),
|
*g_SimplePool, charInfo.GetIceModelId(), charInfo.GetIceSkinRulesId(), charInfo.GetCharLayoutInfoId(), 0));
|
||||||
charInfo.GetCharLayoutInfoId(), 0, tag.type.toUint32() >> 16));
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -78,21 +76,20 @@ std::unique_ptr<u8[]> CCharacterFactory::CDummyFactory::LoadNewResourcePartSync(
|
||||||
|
|
||||||
std::unique_ptr<CAnimData> CCharacterFactory::CreateCharacter(int charIdx, bool loop,
|
std::unique_ptr<CAnimData> CCharacterFactory::CreateCharacter(int charIdx, bool loop,
|
||||||
const TLockedToken<CCharacterFactory>& factory,
|
const TLockedToken<CCharacterFactory>& factory,
|
||||||
int defaultAnim, int drawInsts) {
|
int defaultAnim) {
|
||||||
const CCharacterInfo& charInfo = x4_charInfoDB[charIdx];
|
const CCharacterInfo& charInfo = x4_charInfoDB[charIdx];
|
||||||
const CVParamTransfer charParm(new TObjOwnerParam<const CCharacterInfo*>(&charInfo));
|
const CVParamTransfer charParm(new TObjOwnerParam<const CCharacterInfo*>(&charInfo));
|
||||||
|
|
||||||
TToken<CSkinnedModel> skinnedModel =
|
TToken<CSkinnedModel> skinnedModel = x70_cacheResPool.GetObj({FourCC(0u), charInfo.GetModelId()}, charParm);
|
||||||
x70_cacheResPool.GetObj({FourCC(drawInsts << 16), charInfo.GetModelId()}, charParm);
|
|
||||||
|
|
||||||
std::optional<TToken<CMorphableSkinnedModel>> iceModel;
|
std::optional<TToken<CMorphableSkinnedModel>> iceModel;
|
||||||
if (charInfo.GetIceModelId().IsValid() && charInfo.GetIceSkinRulesId().IsValid()) {
|
if (charInfo.GetIceModelId().IsValid() && charInfo.GetIceSkinRulesId().IsValid()) {
|
||||||
iceModel.emplace(x70_cacheResPool.GetObj({FourCC((drawInsts << 16) | 1), charInfo.GetIceModelId()}, charParm));
|
iceModel.emplace(x70_cacheResPool.GetObj({FourCC(1u), charInfo.GetIceModelId()}, charParm));
|
||||||
}
|
}
|
||||||
|
|
||||||
return std::make_unique<CAnimData>(x68_selfId, charInfo, defaultAnim, charIdx, loop, x14_charLayoutInfoDB[charIdx],
|
return std::make_unique<CAnimData>(x68_selfId, charInfo, defaultAnim, charIdx, loop, x14_charLayoutInfoDB[charIdx],
|
||||||
std::move(skinnedModel), iceModel, x24_sysContext, x28_animMgr, x2c_transMgr,
|
std::move(skinnedModel), iceModel, x24_sysContext, x28_animMgr, x2c_transMgr,
|
||||||
factory, drawInsts);
|
factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
CAssetId CCharacterFactory::GetEventResourceIdForAnimResourceId(CAssetId id) const {
|
CAssetId CCharacterFactory::GetEventResourceIdForAnimResourceId(CAssetId id) const {
|
||||||
|
@ -156,8 +153,9 @@ CCharacterFactory::CCharacterFactory(CSimplePool& store, const CAnimCharacterSet
|
||||||
std::vector<CPrimitive> primitives;
|
std::vector<CPrimitive> primitives;
|
||||||
x28_animMgr->GetAnimationDatabase()->GetAllUniquePrimitives(primitives);
|
x28_animMgr->GetAnimationDatabase()->GetAllUniquePrimitives(primitives);
|
||||||
x30_animSourceDB.reserve(primitives.size());
|
x30_animSourceDB.reserve(primitives.size());
|
||||||
for (const CPrimitive& prim : primitives)
|
for (const CPrimitive& prim : primitives) {
|
||||||
x30_animSourceDB.push_back(store.GetObj({SBIG('ANIM'), prim.GetAnimResId()}));
|
x30_animSourceDB.emplace_back(store.GetObj({SBIG('ANIM'), prim.GetAnimResId()}));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace metaforce
|
} // namespace metaforce
|
||||||
|
|
|
@ -68,7 +68,7 @@ public:
|
||||||
CCharacterFactory(CSimplePool& store, const CAnimCharacterSet& ancs, CAssetId);
|
CCharacterFactory(CSimplePool& store, const CAnimCharacterSet& ancs, CAssetId);
|
||||||
|
|
||||||
std::unique_ptr<CAnimData> CreateCharacter(int charIdx, bool loop, const TLockedToken<CCharacterFactory>& factory,
|
std::unique_ptr<CAnimData> CreateCharacter(int charIdx, bool loop, const TLockedToken<CCharacterFactory>& factory,
|
||||||
int defaultAnim, int drawInsts);
|
int defaultAnim);
|
||||||
CAssetId GetEventResourceIdForAnimResourceId(CAssetId animId) const;
|
CAssetId GetEventResourceIdForAnimResourceId(CAssetId animId) const;
|
||||||
|
|
||||||
const CCharacterInfo& GetCharInfo(int charIdx) const { return x4_charInfoDB[charIdx]; }
|
const CCharacterInfo& GetCharInfo(int charIdx) const { return x4_charInfoDB[charIdx]; }
|
||||||
|
|
|
@ -23,17 +23,17 @@ CModelData::~CModelData() = default;
|
||||||
CModelData::CModelData() {}
|
CModelData::CModelData() {}
|
||||||
CModelData CModelData::CModelDataNull() { return CModelData(); }
|
CModelData CModelData::CModelDataNull() { return CModelData(); }
|
||||||
|
|
||||||
CModelData::CModelData(const CStaticRes& res, int instCount) : x0_scale(res.GetScale()), m_drawInstCount(instCount) {
|
CModelData::CModelData(const CStaticRes& res) : x0_scale(res.GetScale()) {
|
||||||
x1c_normalModel = g_SimplePool->GetObj({SBIG('CMDL'), res.GetId()});
|
x1c_normalModel = g_SimplePool->GetObj({SBIG('CMDL'), res.GetId()});
|
||||||
if (!x1c_normalModel)
|
if (!x1c_normalModel)
|
||||||
Log.report(logvisor::Fatal, FMT_STRING("unable to find CMDL {}"), res.GetId());
|
Log.report(logvisor::Fatal, FMT_STRING("unable to find CMDL {}"), res.GetId());
|
||||||
m_normalModelInst = x1c_normalModel->MakeNewInstance(0, instCount);
|
m_normalModelInst = x1c_normalModel->MakeNewInstance(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
CModelData::CModelData(const CAnimRes& res, int instCount) : x0_scale(res.GetScale()), m_drawInstCount(instCount) {
|
CModelData::CModelData(const CAnimRes& res) : x0_scale(res.GetScale()) {
|
||||||
TToken<CCharacterFactory> factory = g_CharFactoryBuilder->GetFactory(res);
|
TToken<CCharacterFactory> factory = g_CharFactoryBuilder->GetFactory(res);
|
||||||
x10_animData =
|
x10_animData =
|
||||||
factory->CreateCharacter(res.GetCharacterNodeId(), res.CanLoop(), factory, res.GetDefaultAnim(), instCount);
|
factory->CreateCharacter(res.GetCharacterNodeId(), res.CanLoop(), factory, res.GetDefaultAnim());
|
||||||
}
|
}
|
||||||
|
|
||||||
SAdvancementDeltas CModelData::GetAdvancementDeltas(const CCharAnimTime& a, const CCharAnimTime& b) const {
|
SAdvancementDeltas CModelData::GetAdvancementDeltas(const CCharAnimTime& a, const CCharAnimTime& b) const {
|
||||||
|
@ -143,7 +143,7 @@ void CModelData::SetXRayModel(const std::pair<CAssetId, CAssetId>& modelSkin) {
|
||||||
x2c_xrayModel = g_SimplePool->GetObj({SBIG('CMDL'), modelSkin.first});
|
x2c_xrayModel = g_SimplePool->GetObj({SBIG('CMDL'), modelSkin.first});
|
||||||
if (!x2c_xrayModel)
|
if (!x2c_xrayModel)
|
||||||
Log.report(logvisor::Fatal, FMT_STRING("unable to find CMDL {}"), modelSkin.first);
|
Log.report(logvisor::Fatal, FMT_STRING("unable to find CMDL {}"), modelSkin.first);
|
||||||
m_xrayModelInst = x2c_xrayModel->MakeNewInstance(0, m_drawInstCount);
|
m_xrayModelInst = x2c_xrayModel->MakeNewInstance(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -160,7 +160,7 @@ void CModelData::SetInfraModel(const std::pair<CAssetId, CAssetId>& modelSkin) {
|
||||||
x3c_infraModel = g_SimplePool->GetObj({SBIG('CMDL'), modelSkin.first});
|
x3c_infraModel = g_SimplePool->GetObj({SBIG('CMDL'), modelSkin.first});
|
||||||
if (!x3c_infraModel)
|
if (!x3c_infraModel)
|
||||||
Log.report(logvisor::Fatal, FMT_STRING("unable to find CMDL {}"), modelSkin.first);
|
Log.report(logvisor::Fatal, FMT_STRING("unable to find CMDL {}"), modelSkin.first);
|
||||||
m_infraModelInst = x3c_infraModel->MakeNewInstance(0, m_drawInstCount);
|
m_infraModelInst = x3c_infraModel->MakeNewInstance(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -431,7 +431,7 @@ void CModelData::DisintegrateDraw(EWhichModel which, const zeus::CTransform& xf,
|
||||||
zeus::CTransform scaledXf = xf * zeus::CTransform::Scale(x0_scale);
|
zeus::CTransform scaledXf = xf * zeus::CTransform::Scale(x0_scale);
|
||||||
CGraphics::SetModelMatrix(scaledXf);
|
CGraphics::SetModelMatrix(scaledXf);
|
||||||
|
|
||||||
CBooModel::SetDisintegrateTexture(tex.GetBooTexture());
|
CBooModel::SetDisintegrateTexture(tex.GetTexture());
|
||||||
CModelFlags flags(5, 0, 3, zeus::skWhite);
|
CModelFlags flags(5, 0, 3, zeus::skWhite);
|
||||||
flags.m_extendedShader = EExtendedShader::Disintegrate;
|
flags.m_extendedShader = EExtendedShader::Disintegrate;
|
||||||
flags.addColor = addColor;
|
flags.addColor = addColor;
|
||||||
|
|
|
@ -75,8 +75,6 @@ class CModelData {
|
||||||
std::unique_ptr<CBooModel> m_xrayModelInst;
|
std::unique_ptr<CBooModel> m_xrayModelInst;
|
||||||
std::unique_ptr<CBooModel> m_infraModelInst;
|
std::unique_ptr<CBooModel> m_infraModelInst;
|
||||||
|
|
||||||
int m_drawInstCount = 0;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum class EWhichModel { Normal, XRay, Thermal, ThermalHot };
|
enum class EWhichModel { Normal, XRay, Thermal, ThermalHot };
|
||||||
|
|
||||||
|
@ -84,8 +82,8 @@ public:
|
||||||
bool GetSortThermal() const { return x14_25_sortThermal; }
|
bool GetSortThermal() const { return x14_25_sortThermal; }
|
||||||
|
|
||||||
~CModelData();
|
~CModelData();
|
||||||
explicit CModelData(const CStaticRes& res, int instCount = 1);
|
explicit CModelData(const CStaticRes& res);
|
||||||
explicit CModelData(const CAnimRes& res, int instCount = 1);
|
explicit CModelData(const CAnimRes& res);
|
||||||
CModelData(CModelData&&) = default;
|
CModelData(CModelData&&) = default;
|
||||||
CModelData& operator=(CModelData&&) = default;
|
CModelData& operator=(CModelData&&) = default;
|
||||||
CModelData();
|
CModelData();
|
||||||
|
|
|
@ -6,45 +6,61 @@
|
||||||
|
|
||||||
namespace metaforce {
|
namespace metaforce {
|
||||||
|
|
||||||
CSkinRules::CSkinRules(CInputStream& in) {
|
static u32 ReadCount(CInputStream& in) {
|
||||||
u32 bankCount = in.readUint32Big();
|
u32 result = in.readUint32Big();
|
||||||
x0_skinBanks.reserve(bankCount);
|
if (result == UINT32_MAX) {
|
||||||
for (u32 i = 0; i < bankCount; ++i)
|
return in.readUint32Big();
|
||||||
x0_skinBanks.emplace_back(in);
|
|
||||||
|
|
||||||
u32 virtualBoneCount = in.readUint32Big();
|
|
||||||
m_virtualBones.reserve(virtualBoneCount);
|
|
||||||
for (u32 i = 0; i < virtualBoneCount; ++i)
|
|
||||||
m_virtualBones.emplace_back(in);
|
|
||||||
|
|
||||||
u32 poolSz = in.readUint32Big();
|
|
||||||
m_poolToSkinIdx.reserve(poolSz);
|
|
||||||
for (u32 i = 0; i < poolSz; ++i)
|
|
||||||
m_poolToSkinIdx.push_back(in.readUint32Big());
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSkinRules::TransformVerticesCPU(std::vector<std::pair<zeus::CVector3f, zeus::CVector3f>>& vnOut,
|
|
||||||
const CPoseAsTransforms& pose, const CModel& model) const {
|
|
||||||
OPTICK_EVENT();
|
|
||||||
vnOut.resize(m_poolToSkinIdx.size());
|
|
||||||
for (size_t i = 0; i < m_poolToSkinIdx.size(); ++i) {
|
|
||||||
const CVirtualBone& vb = m_virtualBones[m_poolToSkinIdx[i]];
|
|
||||||
zeus::CVector3f origVertex = model.GetPoolVertex(i);
|
|
||||||
zeus::CVector3f vertex;
|
|
||||||
zeus::CVector3f origNormal = model.GetPoolNormal(i);
|
|
||||||
zeus::CVector3f normal;
|
|
||||||
for (const SSkinWeighting& w : vb.GetWeights()) {
|
|
||||||
const zeus::CTransform& xf = pose.GetRestToAccumTransform(w.m_id);
|
|
||||||
vertex += (xf * origVertex) * w.m_weight;
|
|
||||||
normal += (xf.basis.inverted().transposed() * origNormal) * w.m_weight;
|
|
||||||
}
|
|
||||||
vnOut[i] = std::make_pair(vertex, normal.normalized());
|
|
||||||
}
|
}
|
||||||
|
in.seek(s64(result) * 3);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CSkinRules::CSkinRules(CInputStream& in) {
|
||||||
|
u32 weightCount = in.readUint32Big();
|
||||||
|
x0_bones.reserve(weightCount);
|
||||||
|
for (int i = 0; i < weightCount; ++i) {
|
||||||
|
x0_bones.emplace_back(in);
|
||||||
|
}
|
||||||
|
x10_vertexCount = ReadCount(in);
|
||||||
|
x14_normalCount = ReadCount(in);
|
||||||
|
}
|
||||||
|
|
||||||
|
// void CSkinRules::TransformVerticesCPU(std::vector<std::pair<zeus::CVector3f, zeus::CVector3f>>& vnOut,
|
||||||
|
// const CPoseAsTransforms& pose, const CModel& model) const {
|
||||||
|
// OPTICK_EVENT();
|
||||||
|
// vnOut.resize(m_poolToSkinIdx.size());
|
||||||
|
// for (size_t i = 0; i < m_poolToSkinIdx.size(); ++i) {
|
||||||
|
// const CVirtualBone& vb = m_virtualBones[m_poolToSkinIdx[i]];
|
||||||
|
// zeus::CVector3f origVertex = model.GetPoolVertex(i);
|
||||||
|
// zeus::CVector3f vertex;
|
||||||
|
// zeus::CVector3f origNormal = model.GetPoolNormal(i);
|
||||||
|
// zeus::CVector3f normal;
|
||||||
|
// for (const SSkinWeighting& w : vb.GetWeights()) {
|
||||||
|
// const zeus::CTransform& xf = pose.GetRestToAccumTransform(w.m_id);
|
||||||
|
// vertex += (xf * origVertex) * w.m_weight;
|
||||||
|
// normal += (xf.basis.inverted().transposed() * origNormal) * w.m_weight;
|
||||||
|
// }
|
||||||
|
// vnOut[i] = std::make_pair(vertex, normal.normalized());
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
CFactoryFnReturn FSkinRulesFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& params,
|
CFactoryFnReturn FSkinRulesFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& params,
|
||||||
CObjectReference* selfRef) {
|
CObjectReference* selfRef) {
|
||||||
return TToken<CSkinRules>::GetIObjObjectFor(std::make_unique<CSkinRules>(in));
|
return TToken<CSkinRules>::GetIObjObjectFor(std::make_unique<CSkinRules>(in));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto StreamInSkinWeighting(CInputStream& in) {
|
||||||
|
rstl::reserved_vector<SSkinWeighting, 3> weights;
|
||||||
|
u32 weightCount = in.readUint32Big();
|
||||||
|
for (int i = 0; i < std::min(3u, weightCount); ++i) {
|
||||||
|
weights.emplace_back(in);
|
||||||
|
}
|
||||||
|
for (int i = 3; i < weightCount; ++i) {
|
||||||
|
SSkinWeighting{in};
|
||||||
|
}
|
||||||
|
return weights;
|
||||||
|
}
|
||||||
|
|
||||||
|
CVirtualBone::CVirtualBone(CInputStream& in)
|
||||||
|
: x0_weights(StreamInSkinWeighting(in)), x1c_vertexCount(in.readUint32Big()) {}
|
||||||
} // namespace metaforce
|
} // namespace metaforce
|
||||||
|
|
|
@ -3,10 +3,9 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "Runtime/CFactoryMgr.hpp"
|
#include "Runtime/CFactoryMgr.hpp"
|
||||||
#include "Runtime/RetroTypes.hpp"
|
|
||||||
#include "Runtime/Character/CSkinBank.hpp"
|
#include "Runtime/Character/CSkinBank.hpp"
|
||||||
|
#include "Runtime/RetroTypes.hpp"
|
||||||
|
|
||||||
#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
|
||||||
#include <zeus/CVector3f.hpp>
|
#include <zeus/CVector3f.hpp>
|
||||||
|
|
||||||
namespace metaforce {
|
namespace metaforce {
|
||||||
|
@ -14,46 +13,42 @@ class CPoseAsTransforms;
|
||||||
class CModel;
|
class CModel;
|
||||||
|
|
||||||
struct SSkinWeighting {
|
struct SSkinWeighting {
|
||||||
CSegId m_id;
|
CSegId x0_id;
|
||||||
float m_weight;
|
float x4_weight;
|
||||||
explicit SSkinWeighting(CInputStream& in) : m_id(in), m_weight(in.readFloatBig()) {}
|
explicit SSkinWeighting(CInputStream& in) : x0_id(in), x4_weight(in.readFloatBig()) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
class CVirtualBone {
|
class CVirtualBone {
|
||||||
std::vector<SSkinWeighting> m_weights;
|
rstl::reserved_vector<SSkinWeighting, 3> x0_weights;
|
||||||
|
u32 x1c_vertexCount;
|
||||||
|
zeus::CTransform x20_xf;
|
||||||
|
zeus::CMatrix3f x50_mtx;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit CVirtualBone(CInputStream& in) {
|
explicit CVirtualBone(CInputStream& in);
|
||||||
u32 weightCount = in.readUint32Big();
|
|
||||||
m_weights.reserve(weightCount);
|
|
||||||
for (u32 i = 0; i < weightCount; ++i)
|
|
||||||
m_weights.emplace_back(in);
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::vector<SSkinWeighting>& GetWeights() const { return m_weights; }
|
[[nodiscard]] const rstl::reserved_vector<SSkinWeighting, 3>& GetWeights() const { return x0_weights; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class CSkinRules {
|
class CSkinRules {
|
||||||
std::vector<CSkinBank> x0_skinBanks;
|
std::vector<CVirtualBone> x0_bones;
|
||||||
// u32 x10_vertexCount;
|
u32 x10_vertexCount;
|
||||||
// u32 x14_normalCount;
|
u32 x14_normalCount;
|
||||||
std::vector<CVirtualBone> m_virtualBones;
|
|
||||||
std::vector<u32> m_poolToSkinIdx;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit CSkinRules(CInputStream& in);
|
explicit CSkinRules(CInputStream& in);
|
||||||
|
|
||||||
void GetBankTransforms(std::vector<const zeus::CTransform*>& out, const CPoseAsTransforms& pose,
|
// void GetBankTransforms(std::vector<const zeus::CTransform*>& out, const CPoseAsTransforms& pose,
|
||||||
int skinBankIdx) const {
|
// int skinBankIdx) const {
|
||||||
// FIXME: This is definitely not proper behavior, this is here to fix the phazon suit crashing
|
// // FIXME: This is definitely not proper behavior, this is here to fix the phazon suit crashing
|
||||||
if (x0_skinBanks.size() <= skinBankIdx) {
|
// if (x0_skinBanks.size() <= skinBankIdx) {
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
x0_skinBanks[skinBankIdx].GetBankTransforms(out, pose);
|
// x0_skinBanks[skinBankIdx].GetBankTransforms(out, pose);
|
||||||
}
|
// }
|
||||||
|
|
||||||
void TransformVerticesCPU(std::vector<std::pair<zeus::CVector3f, zeus::CVector3f>>& vnOut,
|
// void TransformVerticesCPU(std::vector<std::pair<zeus::CVector3f, zeus::CVector3f>>& vnOut,
|
||||||
const CPoseAsTransforms& pose, const CModel& model) const;
|
// const CPoseAsTransforms& pose, const CModel& model) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
CFactoryFnReturn FSkinRulesFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& params,
|
CFactoryFnReturn FSkinRulesFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& params,
|
||||||
|
|
|
@ -410,8 +410,7 @@ void CBooRenderer::DrawFogSlices(const zeus::CPlane* planes, size_t numPlanes, s
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBooRenderer::RenderFogVolumeModel(const zeus::CAABox& aabb, const CModel* model, const zeus::CTransform& modelMtx,
|
void CBooRenderer::RenderFogVolumeModel(const zeus::CAABox& aabb, const CModel* model, const zeus::CTransform& modelMtx,
|
||||||
const zeus::CTransform& viewMtx, const CSkinnedModel* sModel, int pass,
|
const zeus::CTransform& viewMtx, const CSkinnedModel* sModel, int pass) {
|
||||||
CFogVolumePlaneShader* fvs) {
|
|
||||||
if (!model && !sModel) {
|
if (!model && !sModel) {
|
||||||
if (pass == 0) {
|
if (pass == 0) {
|
||||||
zeus::CAABox xfAABB = aabb.getTransformedAABox(modelMtx);
|
zeus::CAABox xfAABB = aabb.getTransformedAABox(modelMtx);
|
||||||
|
@ -432,13 +431,14 @@ void CBooRenderer::RenderFogVolumeModel(const zeus::CAABox& aabb, const CModel*
|
||||||
xfAABB.max.z() - xfAABB.min.z()) *
|
xfAABB.max.z() - xfAABB.min.z()) *
|
||||||
2.f;
|
2.f;
|
||||||
|
|
||||||
fvs->reset(7 * 6);
|
CFogVolumePlaneShader fvs;
|
||||||
|
fvs.reset(7 * 6);
|
||||||
for (size_t i = 0; i < planes.size(); ++i) {
|
for (size_t i = 0; i < planes.size(); ++i) {
|
||||||
DrawFogSlices(planes.data(), planes.size(), i, xfAABB.center(), longestAxis, *fvs);
|
DrawFogSlices(planes.data(), planes.size(), i, xfAABB.center(), longestAxis, fvs);
|
||||||
}
|
}
|
||||||
fvs->draw(0);
|
aurora::shaders::queue_fog_volume_plane(fvs.m_verts, 0);
|
||||||
} else {
|
} else {
|
||||||
fvs->draw(pass);
|
aurora::shaders::queue_fog_volume_plane({}, pass);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
CModelFlags flags;
|
CModelFlags flags;
|
||||||
|
@ -547,140 +547,132 @@ void CBooRenderer::ReallyRenderFogVolume(const zeus::CColor& color, const zeus::
|
||||||
zeus::CAABox marginAABB((CGraphics::g_GXModelView * aabb.min) - 1.f, (CGraphics::g_GXModelView * aabb.max) + 1.f);
|
zeus::CAABox marginAABB((CGraphics::g_GXModelView * aabb.min) - 1.f, (CGraphics::g_GXModelView * aabb.max) + 1.f);
|
||||||
bool camInModel = marginAABB.pointInside(CGraphics::g_ViewMatrix.origin) && (model || sModel);
|
bool camInModel = marginAABB.pointInside(CGraphics::g_ViewMatrix.origin) && (model || sModel);
|
||||||
|
|
||||||
CFogVolumePlaneShader* fvs;
|
// CFogVolumePlaneShader* fvs;
|
||||||
if (!model && !sModel) {
|
// if (!model && !sModel) {
|
||||||
fvs = &*((m_nextFogVolumePlaneShader == m_fogVolumePlaneShaders.end())
|
// fvs = &*((m_nextFogVolumePlaneShader == m_fogVolumePlaneShaders.end())
|
||||||
? m_fogVolumePlaneShaders.insert(m_fogVolumePlaneShaders.end(), CFogVolumePlaneShader())
|
// ? m_fogVolumePlaneShaders.insert(m_fogVolumePlaneShaders.end(), CFogVolumePlaneShader())
|
||||||
: m_nextFogVolumePlaneShader++);
|
// : m_nextFogVolumePlaneShader++);
|
||||||
} else {
|
// } else {
|
||||||
fvs = nullptr;
|
// fvs = nullptr;
|
||||||
}
|
// }
|
||||||
|
|
||||||
RenderFogVolumeModel(aabb, model, CGraphics::g_GXModelMatrix, CGraphics::g_ViewMatrix, sModel, 0, fvs);
|
RenderFogVolumeModel(aabb, model, CGraphics::g_GXModelMatrix, CGraphics::g_ViewMatrix, sModel, 0);
|
||||||
if (camInModel)
|
if (camInModel)
|
||||||
RenderFogVolumeModel(aabb, model, CGraphics::g_GXModelMatrix, CGraphics::g_ViewMatrix, sModel, 1, fvs);
|
RenderFogVolumeModel(aabb, model, CGraphics::g_GXModelMatrix, CGraphics::g_ViewMatrix, sModel, 1);
|
||||||
|
|
||||||
CGraphics::ResolveSpareDepth(rect, 0);
|
CGraphics::ResolveSpareDepth(rect, 0);
|
||||||
|
|
||||||
RenderFogVolumeModel(aabb, model, CGraphics::g_GXModelMatrix, CGraphics::g_ViewMatrix, sModel, 2, fvs);
|
RenderFogVolumeModel(aabb, model, CGraphics::g_GXModelMatrix, CGraphics::g_ViewMatrix, sModel, 2);
|
||||||
if (camInModel)
|
if (camInModel)
|
||||||
RenderFogVolumeModel(aabb, model, CGraphics::g_GXModelMatrix, CGraphics::g_ViewMatrix, sModel, 3, fvs);
|
RenderFogVolumeModel(aabb, model, CGraphics::g_GXModelMatrix, CGraphics::g_ViewMatrix, sModel, 3);
|
||||||
|
|
||||||
CGraphics::ResolveSpareDepth(rect, 1);
|
CGraphics::ResolveSpareDepth(rect, 1);
|
||||||
|
|
||||||
auto fvf = (m_nextFogVolumeFilter == m_fogVolumeFilters.end())
|
aurora::shaders::queue_fog_volume_filter(color, true);
|
||||||
? m_fogVolumeFilters.insert(m_fogVolumeFilters.end(), CFogVolumeFilter())
|
|
||||||
: m_nextFogVolumeFilter++;
|
|
||||||
fvf->draw2WayPass(color);
|
|
||||||
if (camInModel)
|
if (camInModel)
|
||||||
fvf->draw1WayPass(color);
|
aurora::shaders::queue_fog_volume_filter(color, false);
|
||||||
|
|
||||||
// CGraphics::SetScissor(g_Viewport.x0_left, g_Viewport.x4_top, g_Viewport.x8_width, g_Viewport.xc_height);
|
// CGraphics::SetScissor(g_Viewport.x0_left, g_Viewport.x4_top, g_Viewport.x8_width, g_Viewport.xc_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBooRenderer::GenerateFogVolumeRampTex(boo::IGraphicsDataFactory::Context& ctx) {
|
//void CBooRenderer::GenerateFogVolumeRampTex() {
|
||||||
std::array<std::array<u16, FOGVOL_RAMP_RES>, FOGVOL_RAMP_RES> data{};
|
// std::array<std::array<float, FOGVOL_RAMP_RES>, FOGVOL_RAMP_RES> data{};
|
||||||
for (size_t y = 0; y < data.size(); ++y) {
|
// for (size_t y = 0; y < data.size(); ++y) {
|
||||||
for (size_t x = 0; x < data[y].size(); ++x) {
|
// for (size_t x = 0; x < data[y].size(); ++x) {
|
||||||
const int tmp = int(y << 16 | x << 8 | 0x7f);
|
// const int tmp = int(y << 16 | x << 8 | 0x7f);
|
||||||
const double a =
|
// const double a =
|
||||||
zeus::clamp(0.0,
|
// zeus::clamp(0.0,
|
||||||
(-150.0 / (tmp / double(0xffffff) * (FOGVOL_FAR - FOGVOL_NEAR) - FOGVOL_FAR) - FOGVOL_NEAR) *
|
// (-150.0 / (tmp / double(0xffffff) * (FOGVOL_FAR - FOGVOL_NEAR) - FOGVOL_FAR) - FOGVOL_NEAR) *
|
||||||
3.0 / (FOGVOL_FAR - FOGVOL_NEAR),
|
// 3.0 / (FOGVOL_FAR - FOGVOL_NEAR),
|
||||||
1.0);
|
// 1.0);
|
||||||
data[y][x] = u16((a * a + a) / 2.0 * 65535);
|
// data[y][x] = (a * a + a) / 2.0;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
x1b8_fogVolumeRamp =
|
// x1b8_fogVolumeRamp =
|
||||||
ctx.newStaticTexture(FOGVOL_RAMP_RES, FOGVOL_RAMP_RES, 1, boo::TextureFormat::I16, boo::TextureClampMode::Repeat,
|
// aurora::new_static_texture_2d(FOGVOL_RAMP_RES, FOGVOL_RAMP_RES, 1, aurora::shaders::TextureFormat::R32Float,
|
||||||
data[0].data(), FOGVOL_RAMP_RES * FOGVOL_RAMP_RES * 2);
|
// {data[0].data(), FOGVOL_RAMP_RES * FOGVOL_RAMP_RES * 2});
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
|
//void CBooRenderer::GenerateSphereRampTex() {
|
||||||
|
// std::array<std::array<u8, SPHERE_RAMP_RES>, SPHERE_RAMP_RES> data{};
|
||||||
|
// constexpr float halfRes = SPHERE_RAMP_RES / 2.f;
|
||||||
|
// for (size_t y = 0; y < data.size(); ++y) {
|
||||||
|
// for (size_t x = 0; x < data[y].size(); ++x) {
|
||||||
|
// const zeus::CVector2f vec((float(x) - halfRes) / halfRes, (float(y) - halfRes) / halfRes);
|
||||||
|
// data[y][x] = 255 - zeus::clamp(0.f, vec.canBeNormalized() ? vec.magnitude() : 0.f, 1.f) * 255;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// x220_sphereRamp =
|
||||||
|
// aurora::new_static_texture_2d(SPHERE_RAMP_RES, SPHERE_RAMP_RES, 1, aurora::shaders::TextureFormat::R8,
|
||||||
|
// {data[0].data(), SPHERE_RAMP_RES * SPHERE_RAMP_RES});
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//void CBooRenderer::GenerateScanLinesVBO() {
|
||||||
|
// std::vector<zeus::CVector3f> verts;
|
||||||
|
// verts.reserve(670);
|
||||||
|
//
|
||||||
|
// for (int i = 0; i < 112; ++i) {
|
||||||
|
// verts.emplace_back(-1.f, (float(i) * (4.f / 448.f) + (1.f / 448.f)) * 2.f - 1.f, 0.f);
|
||||||
|
// if (i != 0) {
|
||||||
|
// verts.emplace_back(verts.back());
|
||||||
|
// }
|
||||||
|
// verts.emplace_back(-1.f, (float(i) * (4.f / 448.f) - (1.f / 448.f)) * 2.f - 1.f, 0.f);
|
||||||
|
// verts.emplace_back(1.f, (float(i) * (4.f / 448.f) + (1.f / 448.f)) * 2.f - 1.f, 0.f);
|
||||||
|
// verts.emplace_back(1.f, (float(i) * (4.f / 448.f) - (1.f / 448.f)) * 2.f - 1.f, 0.f);
|
||||||
|
// if (i != 111) {
|
||||||
|
// verts.emplace_back(verts.back());
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// m_scanLinesEvenVBO = ctx.newStaticBuffer(boo::BufferUse::Vertex, verts.data(), sizeof(zeus::CVector3f), verts.size());
|
||||||
|
//
|
||||||
|
// verts.clear();
|
||||||
|
//
|
||||||
|
// for (int i = 0; i < 112; ++i) {
|
||||||
|
// verts.emplace_back(-1.f, (float(i) * (4.f / 448.f) + (3.f / 448.f)) * 2.f - 1.f, 0.f);
|
||||||
|
// if (i != 0) {
|
||||||
|
// verts.emplace_back(verts.back());
|
||||||
|
// }
|
||||||
|
// verts.emplace_back(-1.f, (float(i) * (4.f / 448.f) + (1.f / 448.f)) * 2.f - 1.f, 0.f);
|
||||||
|
// verts.emplace_back(1.f, (float(i) * (4.f / 448.f) + (3.f / 448.f)) * 2.f - 1.f, 0.f);
|
||||||
|
// verts.emplace_back(1.f, (float(i) * (4.f / 448.f) + (1.f / 448.f)) * 2.f - 1.f, 0.f);
|
||||||
|
// if (i != 111) {
|
||||||
|
// verts.emplace_back(verts.back());
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// m_scanLinesOddVBO = ctx.newStaticBuffer(boo::BufferUse::Vertex, verts.data(), sizeof(zeus::CVector3f), verts.size());
|
||||||
|
//}
|
||||||
|
|
||||||
void CBooRenderer::GenerateSphereRampTex(boo::IGraphicsDataFactory::Context& ctx) {
|
std::shared_ptr<aurora::TextureHandle> CBooRenderer::GetColorTexture(const zeus::CColor& color) {
|
||||||
std::array<std::array<u8, SPHERE_RAMP_RES>, SPHERE_RAMP_RES> data{};
|
|
||||||
constexpr float halfRes = SPHERE_RAMP_RES / 2.f;
|
|
||||||
for (size_t y = 0; y < data.size(); ++y) {
|
|
||||||
for (size_t x = 0; x < data[y].size(); ++x) {
|
|
||||||
const zeus::CVector2f vec((float(x) - halfRes) / halfRes, (float(y) - halfRes) / halfRes);
|
|
||||||
data[y][x] = 255 - zeus::clamp(0.f, vec.canBeNormalized() ? vec.magnitude() : 0.f, 1.f) * 255;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
x220_sphereRamp =
|
|
||||||
ctx.newStaticTexture(SPHERE_RAMP_RES, SPHERE_RAMP_RES, 1, boo::TextureFormat::I8,
|
|
||||||
boo::TextureClampMode::ClampToEdge, data[0].data(), SPHERE_RAMP_RES * SPHERE_RAMP_RES);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CBooRenderer::GenerateScanLinesVBO(boo::IGraphicsDataFactory::Context& ctx) {
|
|
||||||
std::vector<zeus::CVector3f> verts;
|
|
||||||
verts.reserve(670);
|
|
||||||
|
|
||||||
for (int i = 0; i < 112; ++i) {
|
|
||||||
verts.emplace_back(-1.f, (float(i) * (4.f / 448.f) + (1.f / 448.f)) * 2.f - 1.f, 0.f);
|
|
||||||
if (i != 0) {
|
|
||||||
verts.emplace_back(verts.back());
|
|
||||||
}
|
|
||||||
verts.emplace_back(-1.f, (float(i) * (4.f / 448.f) - (1.f / 448.f)) * 2.f - 1.f, 0.f);
|
|
||||||
verts.emplace_back(1.f, (float(i) * (4.f / 448.f) + (1.f / 448.f)) * 2.f - 1.f, 0.f);
|
|
||||||
verts.emplace_back(1.f, (float(i) * (4.f / 448.f) - (1.f / 448.f)) * 2.f - 1.f, 0.f);
|
|
||||||
if (i != 111) {
|
|
||||||
verts.emplace_back(verts.back());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
m_scanLinesEvenVBO = ctx.newStaticBuffer(boo::BufferUse::Vertex, verts.data(), sizeof(zeus::CVector3f), verts.size());
|
|
||||||
|
|
||||||
verts.clear();
|
|
||||||
|
|
||||||
for (int i = 0; i < 112; ++i) {
|
|
||||||
verts.emplace_back(-1.f, (float(i) * (4.f / 448.f) + (3.f / 448.f)) * 2.f - 1.f, 0.f);
|
|
||||||
if (i != 0) {
|
|
||||||
verts.emplace_back(verts.back());
|
|
||||||
}
|
|
||||||
verts.emplace_back(-1.f, (float(i) * (4.f / 448.f) + (1.f / 448.f)) * 2.f - 1.f, 0.f);
|
|
||||||
verts.emplace_back(1.f, (float(i) * (4.f / 448.f) + (3.f / 448.f)) * 2.f - 1.f, 0.f);
|
|
||||||
verts.emplace_back(1.f, (float(i) * (4.f / 448.f) + (1.f / 448.f)) * 2.f - 1.f, 0.f);
|
|
||||||
if (i != 111) {
|
|
||||||
verts.emplace_back(verts.back());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
m_scanLinesOddVBO = ctx.newStaticBuffer(boo::BufferUse::Vertex, verts.data(), sizeof(zeus::CVector3f), verts.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
boo::ObjToken<boo::ITexture> CBooRenderer::GetColorTexture(const zeus::CColor& color) {
|
|
||||||
const auto search = m_colorTextures.find(color);
|
const auto search = m_colorTextures.find(color);
|
||||||
if (search != m_colorTextures.end()) {
|
if (search != m_colorTextures.end()) {
|
||||||
return search->second;
|
return search->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::array<u8, 4> pixel;
|
std::array<u8, 4> pixel{};
|
||||||
color.toRGBA8(pixel[0], pixel[1], pixel[2], pixel[3]);
|
color.toRGBA8(pixel[0], pixel[1], pixel[2], pixel[3]);
|
||||||
boo::ObjToken<boo::ITexture> tex;
|
auto tex = aurora::new_static_texture_2d(1, 1, 1, aurora::shaders::TextureFormat::RGBA8, {pixel.data(), pixel.size()},
|
||||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
"Color Texture"sv);
|
||||||
tex = ctx.newStaticTexture(1, 1, 1, boo::TextureFormat::RGBA8, boo::TextureClampMode::Repeat, pixel.data(),
|
|
||||||
pixel.size())
|
|
||||||
.get();
|
|
||||||
return true;
|
|
||||||
} BooTrace);
|
|
||||||
m_colorTextures.emplace(color, tex);
|
m_colorTextures.emplace(color, tex);
|
||||||
return tex;
|
return tex;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBooRenderer::LoadThermoPalette() {
|
//void CBooRenderer::LoadThermoPalette() {
|
||||||
m_thermoPaletteTex = xc_store.GetObj("TXTR_ThermoPalette");
|
// m_thermoPaletteTex = xc_store.GetObj("TXTR_ThermoPalette");
|
||||||
CTexture* thermoTexObj = m_thermoPaletteTex.GetObj();
|
// CTexture* thermoTexObj = m_thermoPaletteTex.GetObj();
|
||||||
if (thermoTexObj)
|
// if (thermoTexObj)
|
||||||
x288_thermoPalette = thermoTexObj->GetPaletteTexture();
|
// x288_thermoPalette = thermoTexObj->GetPaletteTexture();
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
void CBooRenderer::LoadBallFade() {
|
//void CBooRenderer::LoadBallFade() {
|
||||||
m_ballFadeTex = xc_store.GetObj("TXTR_BallFade");
|
// m_ballFadeTex = xc_store.GetObj("TXTR_BallFade");
|
||||||
CTexture* ballFadeTexObj = m_ballFadeTex.GetObj();
|
// CTexture* ballFadeTexObj = m_ballFadeTex.GetObj();
|
||||||
if (ballFadeTexObj) {
|
// if (ballFadeTexObj) {
|
||||||
m_ballFade = ballFadeTexObj->GetBooTexture();
|
// m_ballFade = ballFadeTexObj->GetBooTexture();
|
||||||
m_ballFade->setClampMode(boo::TextureClampMode::ClampToEdge);
|
// m_ballFade->setClampMode(boo::TextureClampMode::ClampToEdge);
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
||||||
CBooRenderer::CBooRenderer(IObjectStore& store, IFactory& resFac)
|
CBooRenderer::CBooRenderer(IObjectStore& store, IFactory& resFac)
|
||||||
: x8_factory(resFac), xc_store(store), x2a8_thermalRand(20) {
|
: x8_factory(resFac), xc_store(store), x2a8_thermalRand(20) {
|
||||||
|
@ -688,36 +680,32 @@ CBooRenderer::CBooRenderer(IObjectStore& store, IFactory& resFac)
|
||||||
|
|
||||||
m_staticEntropy = store.GetObj("RandomStaticEntropy");
|
m_staticEntropy = store.GetObj("RandomStaticEntropy");
|
||||||
|
|
||||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
constexpr std::array<u8, 4> clearPixel{0, 0, 0, 0};
|
||||||
constexpr std::array<u8, 4> clearPixel{0, 0, 0, 0};
|
m_clearTexture = aurora::new_static_texture_2d(1, 1, 1, aurora::shaders::TextureFormat::RGBA8,
|
||||||
m_clearTexture = ctx.newStaticTexture(1, 1, 1, boo::TextureFormat::RGBA8, boo::TextureClampMode::Repeat,
|
{clearPixel.data(), clearPixel.size()}, "Clear Texture"sv);
|
||||||
clearPixel.data(), clearPixel.size())
|
constexpr std::array<u8, 4> blackPixel{0, 0, 0, 255};
|
||||||
.get();
|
m_blackTexture = aurora::new_static_texture_2d(1, 1, 1, aurora::shaders::TextureFormat::RGBA8,
|
||||||
constexpr std::array<u8, 4> blackPixel{0, 0, 0, 255};
|
{blackPixel.data(), blackPixel.size()}, "Black Texture"sv);
|
||||||
m_blackTexture = ctx.newStaticTexture(1, 1, 1, boo::TextureFormat::RGBA8, boo::TextureClampMode::Repeat,
|
constexpr std::array<u8, 4> whitePixel{255, 255, 255, 255};
|
||||||
blackPixel.data(), blackPixel.size())
|
m_whiteTexture = aurora::new_static_texture_2d(1, 1, 1, aurora::shaders::TextureFormat::RGBA8,
|
||||||
.get();
|
{whitePixel.data(), whitePixel.size()}, "White Texture"sv);
|
||||||
constexpr std::array<u8, 4> whitePixel{255, 255, 255, 255};
|
|
||||||
m_whiteTexture = ctx.newStaticTexture(1, 1, 1, boo::TextureFormat::RGBA8, boo::TextureClampMode::Repeat,
|
|
||||||
whitePixel.data(), whitePixel.size())
|
|
||||||
.get();
|
|
||||||
|
|
||||||
GenerateFogVolumeRampTex(ctx);
|
// GenerateFogVolumeRampTex();
|
||||||
GenerateSphereRampTex(ctx);
|
// GenerateSphereRampTex();
|
||||||
m_ballShadowId = ctx.newRenderTexture(m_ballShadowIdW, m_ballShadowIdH, boo::TextureClampMode::Repeat, 1, 0);
|
m_ballShadowId = aurora::new_render_texture(m_ballShadowIdW, m_ballShadowIdH, 1, 0, "Ball Shadow");
|
||||||
x14c_reflectionTex = ctx.newRenderTexture(256, 256, boo::TextureClampMode::ClampToBlack, 1, 0);
|
// m_ballShadowId = ctx.newRenderTexture(m_ballShadowIdW, m_ballShadowIdH, boo::TextureClampMode::Repeat, 1, 0);
|
||||||
GenerateScanLinesVBO(ctx);
|
x14c_reflectionTex = aurora::new_render_texture(256, 256, 1, 0, "Reflection");
|
||||||
return true;
|
// x14c_reflectionTex = ctx.newRenderTexture(256, 256, boo::TextureClampMode::ClampToBlack, 1, 0);
|
||||||
} BooTrace);
|
// GenerateScanLinesVBO();
|
||||||
LoadThermoPalette();
|
// LoadThermoPalette();
|
||||||
LoadBallFade();
|
// LoadBallFade();
|
||||||
m_thermColdFilter.emplace();
|
m_thermColdFilter.emplace();
|
||||||
m_thermHotFilter.emplace();
|
m_thermHotFilter.emplace();
|
||||||
|
|
||||||
Buckets::Init();
|
Buckets::Init();
|
||||||
|
|
||||||
m_nextFogVolumePlaneShader = m_fogVolumePlaneShaders.end();
|
// m_nextFogVolumePlaneShader = m_fogVolumePlaneShaders.end();
|
||||||
m_nextFogVolumeFilter = m_fogVolumeFilters.end();
|
// m_nextFogVolumeFilter = m_fogVolumeFilters.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
CBooRenderer::~CBooRenderer() { g_Renderer = nullptr; }
|
CBooRenderer::~CBooRenderer() { g_Renderer = nullptr; }
|
||||||
|
@ -792,23 +780,20 @@ void CBooRenderer::UpdateAreaUniforms(int areaIdx, EWorldShadowMode shadowMode,
|
||||||
if (areaIdx != -1 && item.x18_areaIdx != areaIdx)
|
if (areaIdx != -1 && item.x18_areaIdx != areaIdx)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
item.m_shaderSet->m_geomLayout->Update(flags, nullptr, nullptr, &item.m_shaderSet->m_matSet,
|
// item.m_shaderSet->m_geomLayout->Update(flags, nullptr, nullptr, &item.m_shaderSet->m_matSet,
|
||||||
item.m_shaderSet->m_geomLayout->GetSharedBuffer(bufIdx), nullptr);
|
// item.m_shaderSet->m_geomLayout->GetSharedBuffer(bufIdx), nullptr);
|
||||||
|
|
||||||
if (shadowMode == EWorldShadowMode::BallOnWorldShadow || shadowMode == EWorldShadowMode::BallOnWorldIds)
|
if (shadowMode == EWorldShadowMode::BallOnWorldShadow || shadowMode == EWorldShadowMode::BallOnWorldIds)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
for (auto it = item.x10_models.begin(); it != item.x10_models.end(); ++it) {
|
||||||
for (auto it = item.x10_models.begin(); it != item.x10_models.end(); ++it) {
|
CBooModel* model = *it;
|
||||||
CBooModel* model = *it;
|
if (model->TryLockTextures()) {
|
||||||
if (model->TryLockTextures()) {
|
if (activateLights)
|
||||||
if (activateLights)
|
ActivateLightsForModel(&item, *model);
|
||||||
ActivateLightsForModel(&item, *model);
|
// model->UpdateUniformData(flags, nullptr, nullptr, bufIdx);
|
||||||
model->UpdateUniformData(flags, nullptr, nullptr, bufIdx, &ctx);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return true;
|
}
|
||||||
} BooTrace);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1084,8 +1069,8 @@ void CBooRenderer::BeginScene() {
|
||||||
x318_26_requestRGBA6 = false;
|
x318_26_requestRGBA6 = false;
|
||||||
// GXSetPixelFmt(x318_27_currentRGBA6);
|
// GXSetPixelFmt(x318_27_currentRGBA6);
|
||||||
CGraphics::BeginScene();
|
CGraphics::BeginScene();
|
||||||
m_nextFogVolumePlaneShader = m_fogVolumePlaneShaders.begin();
|
// m_nextFogVolumePlaneShader = m_fogVolumePlaneShaders.begin();
|
||||||
m_nextFogVolumeFilter = m_fogVolumeFilters.begin();
|
// m_nextFogVolumeFilter = m_fogVolumeFilters.begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBooRenderer::EndScene() {
|
void CBooRenderer::EndScene() {
|
||||||
|
@ -1111,15 +1096,16 @@ void CBooRenderer::CacheReflection(TReflectionCallback cb, void* ctx, bool clear
|
||||||
x318_24_refectionDirty = false;
|
x318_24_refectionDirty = false;
|
||||||
x2dc_reflectionAge = 0;
|
x2dc_reflectionAge = 0;
|
||||||
|
|
||||||
BindReflectionDrawTarget();
|
// TODO
|
||||||
SViewport backupVp = g_Viewport;
|
// BindReflectionDrawTarget();
|
||||||
SetViewport(0, 0, 256, 256);
|
// SViewport backupVp = g_Viewport;
|
||||||
CGraphics::g_BooMainCommandQueue->clearTarget();
|
// SetViewport(0, 0, 256, 256);
|
||||||
cb(ctx, CBooModel::g_ReflectViewPos);
|
// CGraphics::g_BooMainCommandQueue->clearTarget();
|
||||||
boo::SWindowRect rect(0, 0, 256, 256);
|
// cb(ctx, CBooModel::g_ReflectViewPos);
|
||||||
CGraphics::g_BooMainCommandQueue->resolveBindTexture(x14c_reflectionTex, rect, false, 0, true, false);
|
// boo::SWindowRect rect(0, 0, 256, 256);
|
||||||
BindMainDrawTarget();
|
// CGraphics::g_BooMainCommandQueue->resolveBindTexture(x14c_reflectionTex, rect, false, 0, true, false);
|
||||||
SetViewport(backupVp.x0_left, backupVp.x4_top, backupVp.x8_width, backupVp.xc_height);
|
// BindMainDrawTarget();
|
||||||
|
// SetViewport(backupVp.x0_left, backupVp.x4_top, backupVp.x8_width, backupVp.xc_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBooRenderer::DrawSpaceWarp(const zeus::CVector3f& pt, float strength) {
|
void CBooRenderer::DrawSpaceWarp(const zeus::CVector3f& pt, float strength) {
|
||||||
|
@ -1152,7 +1138,7 @@ void CBooRenderer::DrawXRayOutline(const zeus::CAABox& aabb) {
|
||||||
for (u32 b = 0; b < 32; ++b) {
|
for (u32 b = 0; b < 32; ++b) {
|
||||||
if ((bitmap[c] & (1U << b)) != 0) {
|
if ((bitmap[c] & (1U << b)) != 0) {
|
||||||
CBooModel* model = item.x10_models[c * 32 + b];
|
CBooModel* model = item.x10_models[c * 32 + b];
|
||||||
model->UpdateUniformData(flags, nullptr, nullptr);
|
// model->UpdateUniformData(flags, nullptr, nullptr);
|
||||||
const CBooSurface* surf = model->x38_firstUnsortedSurface;
|
const CBooSurface* surf = model->x38_firstUnsortedSurface;
|
||||||
while (surf) {
|
while (surf) {
|
||||||
if (surf->GetBounds().intersects(aabb))
|
if (surf->GetBounds().intersects(aabb))
|
||||||
|
@ -1362,7 +1348,7 @@ int CBooRenderer::DrawOverlappingWorldModelIDs(int alphaVal, const std::vector<u
|
||||||
|
|
||||||
flags.x4_color.a() = static_cast<float>(alphaVal) / 255.f;
|
flags.x4_color.a() = static_cast<float>(alphaVal) / 255.f;
|
||||||
CBooModel& model = *item.x10_models[wordModel + j];
|
CBooModel& model = *item.x10_models[wordModel + j];
|
||||||
model.UpdateUniformData(flags, nullptr, nullptr, 3);
|
// model.UpdateUniformData(flags, nullptr, nullptr, 3);
|
||||||
model.VerifyCurrentShader(0);
|
model.VerifyCurrentShader(0);
|
||||||
for (const CBooSurface* surf = model.x38_firstUnsortedSurface; surf; surf = surf->m_next) {
|
for (const CBooSurface* surf = model.x38_firstUnsortedSurface; surf; surf = surf->m_next) {
|
||||||
if (surf->GetBounds().intersects(aabb)) {
|
if (surf->GetBounds().intersects(aabb)) {
|
||||||
|
@ -1409,7 +1395,7 @@ void CBooRenderer::DrawOverlappingWorldModelShadows(int alphaVal, const std::vec
|
||||||
|
|
||||||
flags.x4_color.r() = static_cast<float>(alphaVal) / 255.f;
|
flags.x4_color.r() = static_cast<float>(alphaVal) / 255.f;
|
||||||
CBooModel& model = *item.x10_models[wordModel + j];
|
CBooModel& model = *item.x10_models[wordModel + j];
|
||||||
model.UpdateUniformData(flags, nullptr, nullptr, 2);
|
// model.UpdateUniformData(flags, nullptr, nullptr, 2);
|
||||||
model.VerifyCurrentShader(0);
|
model.VerifyCurrentShader(0);
|
||||||
for (const CBooSurface* surf = model.x38_firstUnsortedSurface; surf; surf = surf->m_next)
|
for (const CBooSurface* surf = model.x38_firstUnsortedSurface; surf; surf = surf->m_next)
|
||||||
if (surf->GetBounds().intersects(aabb))
|
if (surf->GetBounds().intersects(aabb))
|
||||||
|
|
|
@ -101,31 +101,31 @@ class CBooRenderer final : public IRenderer {
|
||||||
// boo::ITextureS* xe4_blackTex = nullptr;
|
// boo::ITextureS* xe4_blackTex = nullptr;
|
||||||
bool xee_24_ : 1 = true;
|
bool xee_24_ : 1 = true;
|
||||||
|
|
||||||
boo::ObjToken<boo::ITexture> m_clearTexture;
|
std::shared_ptr<aurora::TextureHandle> m_clearTexture;
|
||||||
boo::ObjToken<boo::ITexture> m_blackTexture;
|
std::shared_ptr<aurora::TextureHandle> m_blackTexture;
|
||||||
boo::ObjToken<boo::ITexture> m_whiteTexture;
|
std::shared_ptr<aurora::TextureHandle> m_whiteTexture;
|
||||||
std::unordered_map<zeus::CColor, boo::ObjToken<boo::ITexture>> m_colorTextures;
|
std::unordered_map<zeus::CColor, std::shared_ptr<aurora::TextureHandle>> m_colorTextures;
|
||||||
|
|
||||||
boo::ObjToken<boo::ITextureR> x14c_reflectionTex;
|
std::shared_ptr<aurora::TextureHandle> x14c_reflectionTex;
|
||||||
// boo::ITextureS* x150_mirrorRamp = nullptr;
|
// boo::ITextureS* x150_mirrorRamp = nullptr;
|
||||||
boo::ObjToken<boo::ITextureS> x1b8_fogVolumeRamp;
|
// std::shared_ptr<aurora::TextureHandle> x1b8_fogVolumeRamp;
|
||||||
boo::ObjToken<boo::ITextureS> x220_sphereRamp;
|
std::shared_ptr<aurora::TextureHandle> x220_sphereRamp;
|
||||||
TLockedToken<CTexture> m_thermoPaletteTex;
|
// TLockedToken<CTexture> m_thermoPaletteTex;
|
||||||
boo::ObjToken<boo::ITexture> x288_thermoPalette;
|
// std::shared_ptr<aurora::TextureHandle> x288_thermoPalette;
|
||||||
TLockedToken<CTexture> m_ballFadeTex;
|
// TLockedToken<CTexture> m_ballFadeTex;
|
||||||
boo::ObjToken<boo::ITexture> m_ballFade;
|
std::shared_ptr<aurora::TextureHandle> m_ballFade;
|
||||||
boo::ObjToken<boo::ITextureR> m_ballShadowId;
|
std::shared_ptr<aurora::TextureHandle> m_ballShadowId;
|
||||||
boo::ObjToken<boo::IGraphicsBufferS> m_scanLinesEvenVBO;
|
// boo::ObjToken<boo::IGraphicsBufferS> m_scanLinesEvenVBO;
|
||||||
boo::ObjToken<boo::IGraphicsBufferS> m_scanLinesOddVBO;
|
// boo::ObjToken<boo::IGraphicsBufferS> m_scanLinesOddVBO;
|
||||||
int m_ballShadowIdW = 64;
|
int m_ballShadowIdW = 64;
|
||||||
int m_ballShadowIdH = 64;
|
int m_ballShadowIdH = 64;
|
||||||
|
|
||||||
CRandom16 x2a8_thermalRand;
|
CRandom16 x2a8_thermalRand;
|
||||||
std::list<CFogVolumeListItem> x2ac_fogVolumes;
|
std::list<CFogVolumeListItem> x2ac_fogVolumes;
|
||||||
std::list<CFogVolumePlaneShader> m_fogVolumePlaneShaders;
|
// std::list<CFogVolumePlaneShader> m_fogVolumePlaneShaders;
|
||||||
std::list<CFogVolumePlaneShader>::iterator m_nextFogVolumePlaneShader;
|
// std::list<CFogVolumePlaneShader>::iterator m_nextFogVolumePlaneShader;
|
||||||
std::list<CFogVolumeFilter> m_fogVolumeFilters;
|
// std::list<CFogVolumeFilter> m_fogVolumeFilters;
|
||||||
std::list<CFogVolumeFilter>::iterator m_nextFogVolumeFilter;
|
// std::list<CFogVolumeFilter>::iterator m_nextFogVolumeFilter;
|
||||||
std::list<std::pair<zeus::CVector3f, float>> x2c4_spaceWarps;
|
std::list<std::pair<zeus::CVector3f, float>> x2c4_spaceWarps;
|
||||||
u32 x2dc_reflectionAge = 2;
|
u32 x2dc_reflectionAge = 2;
|
||||||
zeus::CColor x2e0_ = zeus::skWhite;
|
zeus::CColor x2e0_ = zeus::skWhite;
|
||||||
|
@ -156,11 +156,11 @@ class CBooRenderer final : public IRenderer {
|
||||||
bool x318_31_persistRGBA6 : 1 = false;
|
bool x318_31_persistRGBA6 : 1 = false;
|
||||||
bool m_thermalHotPass : 1 = false;
|
bool m_thermalHotPass : 1 = false;
|
||||||
|
|
||||||
void GenerateFogVolumeRampTex(boo::IGraphicsDataFactory::Context& ctx);
|
// void GenerateFogVolumeRampTex();
|
||||||
void GenerateSphereRampTex(boo::IGraphicsDataFactory::Context& ctx);
|
// void GenerateSphereRampTex();
|
||||||
void GenerateScanLinesVBO(boo::IGraphicsDataFactory::Context& ctx);
|
// void GenerateScanLinesVBO();
|
||||||
void LoadThermoPalette();
|
// void LoadThermoPalette();
|
||||||
void LoadBallFade();
|
// void LoadBallFade();
|
||||||
|
|
||||||
void ActivateLightsForModel(CAreaListItem* item, CBooModel& model);
|
void ActivateLightsForModel(CAreaListItem* item, CBooModel& model);
|
||||||
void RenderBucketItems(CAreaListItem* item);
|
void RenderBucketItems(CAreaListItem* item);
|
||||||
|
@ -170,8 +170,7 @@ class CBooRenderer final : public IRenderer {
|
||||||
static void DrawFogSlices(const zeus::CPlane* planes, size_t numPlanes, size_t iteration,
|
static void DrawFogSlices(const zeus::CPlane* planes, size_t numPlanes, size_t iteration,
|
||||||
const zeus::CVector3f& center, float delta, CFogVolumePlaneShader& fogVol);
|
const zeus::CVector3f& center, float delta, CFogVolumePlaneShader& fogVol);
|
||||||
static void RenderFogVolumeModel(const zeus::CAABox& aabb, const CModel* model, const zeus::CTransform& modelMtx,
|
static void RenderFogVolumeModel(const zeus::CAABox& aabb, const CModel* model, const zeus::CTransform& modelMtx,
|
||||||
const zeus::CTransform& viewMtx, const CSkinnedModel* sModel, int pass,
|
const zeus::CTransform& viewMtx, const CSkinnedModel* sModel, int pass);
|
||||||
CFogVolumePlaneShader* fvs);
|
|
||||||
void SetupRendererStates() const;
|
void SetupRendererStates() const;
|
||||||
|
|
||||||
void ReallyDrawPhazonSuitIndirectEffect(const zeus::CColor& vertColor, /*const CTexture& maskTex,*/
|
void ReallyDrawPhazonSuitIndirectEffect(const zeus::CColor& vertColor, /*const CTexture& maskTex,*/
|
||||||
|
@ -264,27 +263,31 @@ public:
|
||||||
void ReallyRenderFogVolume(const zeus::CColor& color, const zeus::CAABox& aabb, const CModel* model,
|
void ReallyRenderFogVolume(const zeus::CColor& color, const zeus::CAABox& aabb, const CModel* model,
|
||||||
const CSkinnedModel* sModel);
|
const CSkinnedModel* sModel);
|
||||||
|
|
||||||
const boo::ObjToken<boo::ITexture>& GetThermoPalette() const { return x288_thermoPalette; }
|
// const boo::ObjToken<boo::ITexture>& GetThermoPalette() const { return x288_thermoPalette; }
|
||||||
const boo::ObjToken<boo::ITextureS>& GetFogRampTex() const { return x1b8_fogVolumeRamp; }
|
// 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::ITexture>& GetRandomStaticEntropyTex() const { return m_staticEntropy->GetBooTexture(); }
|
||||||
const boo::ObjToken<boo::IGraphicsBufferS>& GetScanLinesEvenVBO() const { return m_scanLinesEvenVBO; }
|
// const boo::ObjToken<boo::IGraphicsBufferS>& GetScanLinesEvenVBO() const { return m_scanLinesEvenVBO; }
|
||||||
const boo::ObjToken<boo::IGraphicsBufferS>& GetScanLinesOddVBO() const { return m_scanLinesOddVBO; }
|
// const boo::ObjToken<boo::IGraphicsBufferS>& GetScanLinesOddVBO() const { return m_scanLinesOddVBO; }
|
||||||
|
|
||||||
const boo::ObjToken<boo::ITexture>& GetClearTexture() const { return m_clearTexture; }
|
const std::shared_ptr<aurora::TextureHandle>& GetClearTexture() const { return m_clearTexture; }
|
||||||
const boo::ObjToken<boo::ITexture>& GetBlackTexture() const { return m_blackTexture; }
|
const std::shared_ptr<aurora::TextureHandle>& GetBlackTexture() const { return m_blackTexture; }
|
||||||
const boo::ObjToken<boo::ITexture>& GetWhiteTexture() const { return m_whiteTexture; }
|
const std::shared_ptr<aurora::TextureHandle>& GetWhiteTexture() const { return m_whiteTexture; }
|
||||||
|
|
||||||
boo::ObjToken<boo::ITexture> GetColorTexture(const zeus::CColor& color);
|
std::shared_ptr<aurora::TextureHandle> GetColorTexture(const zeus::CColor& color);
|
||||||
|
|
||||||
static void BindMainDrawTarget() { CGraphics::g_BooMainCommandQueue->setRenderTarget(CGraphics::g_SpareTexture); }
|
static void BindMainDrawTarget() {
|
||||||
void BindReflectionDrawTarget() { CGraphics::g_BooMainCommandQueue->setRenderTarget(x14c_reflectionTex); }
|
// CGraphics::g_BooMainCommandQueue->setRenderTarget(CGraphics::g_SpareTexture);
|
||||||
|
}
|
||||||
|
void BindReflectionDrawTarget() {
|
||||||
|
// CGraphics::g_BooMainCommandQueue->setRenderTarget(x14c_reflectionTex);
|
||||||
|
}
|
||||||
void BindBallShadowIdTarget() {
|
void BindBallShadowIdTarget() {
|
||||||
CGraphics::g_BooMainCommandQueue->setRenderTarget(m_ballShadowId);
|
// CGraphics::g_BooMainCommandQueue->setRenderTarget(m_ballShadowId);
|
||||||
SetViewport(0, 0, m_ballShadowIdW, m_ballShadowIdH);
|
SetViewport(0, 0, m_ballShadowIdW, m_ballShadowIdH);
|
||||||
}
|
}
|
||||||
void ResolveBallShadowIdTarget() {
|
void ResolveBallShadowIdTarget() {
|
||||||
CGraphics::g_BooMainCommandQueue->resolveBindTexture(
|
// CGraphics::g_BooMainCommandQueue->resolveBindTexture(
|
||||||
m_ballShadowId, boo::SWindowRect(0, 0, m_ballShadowIdW, m_ballShadowIdH), false, 0, true, false);
|
// m_ballShadowId, boo::SWindowRect(0, 0, m_ballShadowIdW, m_ballShadowIdH), false, 0, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FindOverlappingWorldModels(std::vector<u32>& modelBits, const zeus::CAABox& aabb) const;
|
void FindOverlappingWorldModels(std::vector<u32>& modelBits, const zeus::CAABox& aabb) const;
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
#include "CCubeModel.hpp"
|
||||||
|
|
||||||
|
#include "CGraphics.hpp"
|
||||||
|
|
||||||
|
namespace metaforce {
|
||||||
|
static const u8* MemoryFromPartData(const u8*& dataCur, const u32*& secSizeCur) {
|
||||||
|
const u8* ret = nullptr;
|
||||||
|
if (*secSizeCur != 0) {
|
||||||
|
ret = dataCur;
|
||||||
|
}
|
||||||
|
dataCur += hecl::SBig(*secSizeCur);
|
||||||
|
++secSizeCur;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
CModel::CModel(std::unique_ptr<u8[]> in, u32 dataLen, IObjectStore* store)
|
||||||
|
: x0_data(std::move(in)), x4_dataLen(dataLen), x38_lastFrame(CGraphics::GetFrameCounter() - 2) {
|
||||||
|
const u8* data = reinterpret_cast<const u8*>(x0_data.get());
|
||||||
|
u32 uVar1 = *reinterpret_cast<const u32*>(data + 8);
|
||||||
|
u32 sectionSizeStart = 0x2c;
|
||||||
|
if (*reinterpret_cast<const u32*>(data + 4) == 1) {
|
||||||
|
sectionSizeStart = 0x28;
|
||||||
|
}
|
||||||
|
const u32* secSizeCur = reinterpret_cast<const u32*>(data + sectionSizeStart);
|
||||||
|
s32 numMatSets = 1;
|
||||||
|
if (*reinterpret_cast<const u32*>(data + 4) > 1) {
|
||||||
|
numMatSets = *reinterpret_cast<const s32*>(data + 0x28);
|
||||||
|
}
|
||||||
|
const auto* dataCur = data + (sectionSizeStart + *reinterpret_cast<const s32*>(data + 0x24) * 4 + 0x1f & 0xffffffe0);
|
||||||
|
x18_matSets.reserve(numMatSets);
|
||||||
|
for (int i = 0; i < numMatSets; i += 1) {
|
||||||
|
x18_matSets.emplace_back(
|
||||||
|
const_cast<CCubeModel*>(reinterpret_cast<const CCubeModel*>(MemoryFromPartData(dataCur, secSizeCur))));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // namespace metaforce
|
|
@ -0,0 +1,37 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "GCNTypes.hpp"
|
||||||
|
#include "IObjectStore.hpp"
|
||||||
|
#include "CTexture.hpp"
|
||||||
|
#include "CToken.hpp"
|
||||||
|
|
||||||
|
namespace metaforce {
|
||||||
|
class CCubeSurface;
|
||||||
|
class CCubeModel;
|
||||||
|
|
||||||
|
struct SShader {
|
||||||
|
std::vector<TCachedToken<CTexture>> x0_textures;
|
||||||
|
CCubeModel* x10_model;
|
||||||
|
|
||||||
|
SShader(CCubeModel* model) : x10_model(model) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
class CModel {
|
||||||
|
std::unique_ptr<u8[]> x0_data;
|
||||||
|
u32 x4_dataLen;
|
||||||
|
std::vector<CCubeSurface*> x8_surfaces;
|
||||||
|
std::vector<SShader> x18_matSets;
|
||||||
|
CCubeModel* x28_modelInst;
|
||||||
|
u16 x2c_;
|
||||||
|
u16 x2e_;
|
||||||
|
CModel* x30_next;
|
||||||
|
CModel* x34_prev;
|
||||||
|
u32 x38_lastFrame;
|
||||||
|
|
||||||
|
public:
|
||||||
|
CModel(std::unique_ptr<u8[]> in, u32 dataLen, IObjectStore* store);
|
||||||
|
};
|
||||||
|
} // namespace metaforce
|
|
@ -37,7 +37,7 @@ u32 CGraphics::g_FrameCounter = 0;
|
||||||
u32 CGraphics::g_Framerate = 0;
|
u32 CGraphics::g_Framerate = 0;
|
||||||
u32 CGraphics::g_FramesPast = 0;
|
u32 CGraphics::g_FramesPast = 0;
|
||||||
frame_clock::time_point CGraphics::g_FrameStartTime = frame_clock::now();
|
frame_clock::time_point CGraphics::g_FrameStartTime = frame_clock::now();
|
||||||
bool CGraphics::g_commitAsLazy = false;
|
//bool CGraphics::g_commitAsLazy = false;
|
||||||
|
|
||||||
const std::array<zeus::CMatrix3f, 6> CGraphics::skCubeBasisMats{{
|
const std::array<zeus::CMatrix3f, 6> CGraphics::skCubeBasisMats{{
|
||||||
/* Right */
|
/* Right */
|
||||||
|
@ -127,7 +127,7 @@ void CGraphics::EndScene() {
|
||||||
CTextSupportShader::UpdateBuffers();
|
CTextSupportShader::UpdateBuffers();
|
||||||
|
|
||||||
/* Same with line renderer */
|
/* Same with line renderer */
|
||||||
CLineRenderer::UpdateBuffers();
|
// CLineRenderer::UpdateBuffers();
|
||||||
|
|
||||||
++g_FrameCounter;
|
++g_FrameCounter;
|
||||||
|
|
||||||
|
@ -156,6 +156,7 @@ void CGraphics::SetViewMatrix() {
|
||||||
g_GXModelViewInvXpose.origin.zeroOut();
|
g_GXModelViewInvXpose.origin.zeroOut();
|
||||||
g_GXModelViewInvXpose.basis.transpose();
|
g_GXModelViewInvXpose.basis.transpose();
|
||||||
/* Load normal matrix */
|
/* Load normal matrix */
|
||||||
|
aurora::shaders::update_model_view(g_GXModelView.toMatrix4f(), g_GXModelViewInvXpose.toMatrix4f());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGraphics::SetModelMatrix(const zeus::CTransform& xf) {
|
void CGraphics::SetModelMatrix(const zeus::CTransform& xf) {
|
||||||
|
@ -192,24 +193,24 @@ 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);
|
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) {
|
// switch (g_BooPlatform) {
|
||||||
case boo::IGraphicsDataFactory::Platform::OpenGL:
|
// case boo::IGraphicsDataFactory::Platform::OpenGL:
|
||||||
default: {
|
// 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,
|
// 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);
|
// 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::D3D11:
|
||||||
case boo::IGraphicsDataFactory::Platform::Metal: {
|
// 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,
|
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);
|
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;
|
return PlusOneZ * mat2;
|
||||||
}
|
// }
|
||||||
case boo::IGraphicsDataFactory::Platform::Vulkan: {
|
// 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,
|
// 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);
|
// 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;
|
// return VulkanCorrect * mat2;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
zeus::CMatrix4f CGraphics::GetPerspectiveProjectionMatrix(bool forRenderer) {
|
zeus::CMatrix4f CGraphics::GetPerspectiveProjectionMatrix(bool forRenderer) {
|
||||||
|
@ -227,27 +228,27 @@ zeus::CMatrix4f CGraphics::GetPerspectiveProjectionMatrix(bool forRenderer) {
|
||||||
0.f, -1.f, 0.f);
|
0.f, -1.f, 0.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (g_BooPlatform) {
|
// switch (g_BooPlatform) {
|
||||||
case boo::IGraphicsDataFactory::Platform::OpenGL:
|
// case boo::IGraphicsDataFactory::Platform::OpenGL:
|
||||||
default: {
|
// 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,
|
// 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,
|
// 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);
|
// 0.f, -1.f, 0.f);
|
||||||
}
|
// }
|
||||||
case boo::IGraphicsDataFactory::Platform::D3D11:
|
// case boo::IGraphicsDataFactory::Platform::D3D11:
|
||||||
case boo::IGraphicsDataFactory::Platform::Metal: {
|
// 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,
|
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,
|
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);
|
0.f, -1.f, 0.f);
|
||||||
return PlusOneZ * mat2;
|
return PlusOneZ * mat2;
|
||||||
}
|
// }
|
||||||
case boo::IGraphicsDataFactory::Platform::Vulkan: {
|
// 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,
|
// 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,
|
// 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);
|
// 0.f, -1.f, 0.f);
|
||||||
return VulkanCorrect * mat2;
|
// return VulkanCorrect * mat2;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
} else {
|
} else {
|
||||||
float rml = g_Proj.x8_right - g_Proj.x4_left;
|
float rml = g_Proj.x8_right - g_Proj.x4_left;
|
||||||
float rpl = g_Proj.x8_right + g_Proj.x4_left;
|
float rpl = g_Proj.x8_right + g_Proj.x4_left;
|
||||||
|
@ -261,24 +262,24 @@ zeus::CMatrix4f CGraphics::GetPerspectiveProjectionMatrix(bool forRenderer) {
|
||||||
-fpn / fmn, 0.f, 0.f, 0.f, 1.f);
|
-fpn / fmn, 0.f, 0.f, 0.f, 1.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (g_BooPlatform) {
|
// switch (g_BooPlatform) {
|
||||||
case boo::IGraphicsDataFactory::Platform::OpenGL:
|
// case boo::IGraphicsDataFactory::Platform::OpenGL:
|
||||||
default: {
|
// 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,
|
// 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);
|
// -fpn / fmn, 0.f, 0.f, 0.f, 1.f);
|
||||||
}
|
// }
|
||||||
case boo::IGraphicsDataFactory::Platform::D3D11:
|
// case boo::IGraphicsDataFactory::Platform::D3D11:
|
||||||
case boo::IGraphicsDataFactory::Platform::Metal: {
|
// 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,
|
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);
|
g_Proj.x14_near / fmn, 0.f, 0.f, 0.f, 1.f);
|
||||||
return PlusOneZ * mat2;
|
return PlusOneZ * mat2;
|
||||||
}
|
// }
|
||||||
case boo::IGraphicsDataFactory::Platform::Vulkan: {
|
// 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,
|
// 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);
|
// -fpn / fmn, 0.f, 0.f, 0.f, 1.f);
|
||||||
return VulkanCorrect * mat2;
|
// return VulkanCorrect * mat2;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -322,6 +323,7 @@ void CGraphics::FlushProjection() {
|
||||||
} else {
|
} else {
|
||||||
// Convert and load ortho
|
// Convert and load ortho
|
||||||
}
|
}
|
||||||
|
aurora::shaders::update_projection(GetPerspectiveProjectionMatrix(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
zeus::CVector2i CGraphics::ProjectPoint(const zeus::CVector3f& point) {
|
zeus::CVector2i CGraphics::ProjectPoint(const zeus::CVector3f& point) {
|
||||||
|
@ -413,26 +415,25 @@ void CGraphics::SetViewportResolution(const zeus::CVector2i& res) {
|
||||||
g_GuiSys->OnViewportResize();
|
g_GuiSys->OnViewportResize();
|
||||||
}
|
}
|
||||||
|
|
||||||
static boo::SWindowRect CachedVP;
|
static zeus::CRectangle CachedVP;
|
||||||
zeus::CVector2f CGraphics::g_CachedDepthRange = {0.f, 1.f};
|
zeus::CVector2f CGraphics::g_CachedDepthRange = {0.f, 1.f};
|
||||||
|
|
||||||
void CGraphics::SetViewport(int leftOff, int bottomOff, int width, int height) {
|
void CGraphics::SetViewport(int leftOff, int bottomOff, int width, int height) {
|
||||||
CachedVP.location[0] = leftOff;
|
CachedVP.position[0] = leftOff;
|
||||||
CachedVP.location[1] = bottomOff;
|
CachedVP.position[1] = bottomOff;
|
||||||
CachedVP.size[0] = width;
|
CachedVP.size[0] = width;
|
||||||
CachedVP.size[1] = height;
|
CachedVP.size[1] = height;
|
||||||
g_BooMainCommandQueue->setViewport(CachedVP, g_CachedDepthRange[0], g_CachedDepthRange[1]);
|
aurora::shaders::set_viewport(CachedVP, g_CachedDepthRange[0], g_CachedDepthRange[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGraphics::SetScissor(int leftOff, int bottomOff, int width, int height) {
|
void CGraphics::SetScissor(int leftOff, int bottomOff, int width, int height) {
|
||||||
boo::SWindowRect rect(leftOff, bottomOff, width, height);
|
aurora::shaders::set_scissor(leftOff, bottomOff, width, height);
|
||||||
g_BooMainCommandQueue->setScissor(rect);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGraphics::SetDepthRange(float znear, float zfar) {
|
void CGraphics::SetDepthRange(float znear, float zfar) {
|
||||||
g_CachedDepthRange[0] = znear;
|
g_CachedDepthRange[0] = znear;
|
||||||
g_CachedDepthRange[1] = zfar;
|
g_CachedDepthRange[1] = zfar;
|
||||||
g_BooMainCommandQueue->setViewport(CachedVP, g_CachedDepthRange[0], g_CachedDepthRange[1]);
|
aurora::shaders::set_viewport(CachedVP, g_CachedDepthRange[0], g_CachedDepthRange[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
CTimeProvider* CGraphics::g_ExternalTimeProvider = nullptr;
|
CTimeProvider* CGraphics::g_ExternalTimeProvider = nullptr;
|
||||||
|
@ -463,11 +464,11 @@ void CGraphics::UpdateFPSCounter() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boo::IGraphicsDataFactory::Platform CGraphics::g_BooPlatform = boo::IGraphicsDataFactory::Platform::Null;
|
//boo::IGraphicsDataFactory::Platform CGraphics::g_BooPlatform = boo::IGraphicsDataFactory::Platform::Null;
|
||||||
boo::IGraphicsDataFactory* CGraphics::g_BooFactory = nullptr;
|
//boo::IGraphicsDataFactory* CGraphics::g_BooFactory = nullptr;
|
||||||
boo::IGraphicsCommandQueue* CGraphics::g_BooMainCommandQueue = nullptr;
|
//boo::IGraphicsCommandQueue* CGraphics::g_BooMainCommandQueue = nullptr;
|
||||||
boo::ObjToken<boo::ITextureR> CGraphics::g_SpareTexture;
|
//boo::ObjToken<boo::ITextureR> CGraphics::g_SpareTexture;
|
||||||
const char* CGraphics::g_BooPlatformName = nullptr;
|
//const char* CGraphics::g_BooPlatformName = nullptr;
|
||||||
|
|
||||||
const CTevCombiners::CTevPass CGraphics::sTevPass805a564c({GX::TevColorArg::CC_ZERO, GX::TevColorArg::CC_ZERO,
|
const CTevCombiners::CTevPass CGraphics::sTevPass805a564c({GX::TevColorArg::CC_ZERO, GX::TevColorArg::CC_ZERO,
|
||||||
GX::TevColorArg::CC_ZERO, GX::TevColorArg::CC_RASC},
|
GX::TevColorArg::CC_ZERO, GX::TevColorArg::CC_RASC},
|
||||||
|
|
|
@ -9,8 +9,8 @@
|
||||||
|
|
||||||
#include "DataSpec/DNACommon/GX.hpp"
|
#include "DataSpec/DNACommon/GX.hpp"
|
||||||
|
|
||||||
#include <boo/graphicsdev/IGraphicsCommandQueue.hpp>
|
//#include <boo/graphicsdev/IGraphicsCommandQueue.hpp>
|
||||||
#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
//#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
||||||
|
|
||||||
#include <hecl/CVar.hpp>
|
#include <hecl/CVar.hpp>
|
||||||
#include <hecl/Runtime.hpp>
|
#include <hecl/Runtime.hpp>
|
||||||
|
@ -20,8 +20,70 @@
|
||||||
#include <zeus/CVector2i.hpp>
|
#include <zeus/CVector2i.hpp>
|
||||||
#include <zeus/CVector2f.hpp>
|
#include <zeus/CVector2f.hpp>
|
||||||
|
|
||||||
|
#include "aurora.h"
|
||||||
|
#include "aurora_shaders.h"
|
||||||
|
|
||||||
using frame_clock = std::chrono::high_resolution_clock;
|
using frame_clock = std::chrono::high_resolution_clock;
|
||||||
|
|
||||||
|
namespace aurora {
|
||||||
|
using TextureRef = aurora::shaders::TextureRef;
|
||||||
|
template <typename T>
|
||||||
|
struct RustDrop {};
|
||||||
|
template <>
|
||||||
|
struct RustDrop<TextureRef> {
|
||||||
|
TextureRef ref;
|
||||||
|
explicit RustDrop(TextureRef ref) : ref(ref) {}
|
||||||
|
~RustDrop() { aurora::shaders::drop_texture(ref); }
|
||||||
|
RustDrop(const RustDrop&) = delete;
|
||||||
|
RustDrop& operator=(const RustDrop&) = delete;
|
||||||
|
};
|
||||||
|
using TextureHandle = RustDrop<TextureRef>;
|
||||||
|
|
||||||
|
inline std::shared_ptr<TextureHandle> new_static_texture_2d(uint32_t width, uint32_t height, uint32_t mips,
|
||||||
|
aurora::shaders::TextureFormat format,
|
||||||
|
rust::Slice<const uint8_t> data,
|
||||||
|
std::string_view label) {
|
||||||
|
rust::Str rlabel{label.data(), label.size()};
|
||||||
|
auto ref = aurora::shaders::create_static_texture_2d(width, height, mips, format, data, rlabel);
|
||||||
|
return std::make_shared<TextureHandle>(ref);
|
||||||
|
}
|
||||||
|
inline std::shared_ptr<TextureHandle> new_render_texture(uint32_t width, uint32_t height,
|
||||||
|
uint32_t color_bind_count, uint32_t depth_bind_count,
|
||||||
|
std::string_view label) {
|
||||||
|
rust::Str rlabel{label.data(), label.size()};
|
||||||
|
auto ref = aurora::shaders::create_render_texture(width, height, color_bind_count, depth_bind_count, rlabel);
|
||||||
|
return std::make_shared<TextureHandle>(ref);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
class ArrayRef {
|
||||||
|
public:
|
||||||
|
using value_type = std::remove_cvref_t<T>;
|
||||||
|
using pointer = value_type*;
|
||||||
|
using const_pointer = const value_type*;
|
||||||
|
using reference = value_type&;
|
||||||
|
using const_reference = const value_type&;
|
||||||
|
using iterator = const_pointer;
|
||||||
|
using const_iterator = const_pointer;
|
||||||
|
using size_type = std::size_t;
|
||||||
|
using difference_type = std::ptrdiff_t;
|
||||||
|
|
||||||
|
ArrayRef() = default;
|
||||||
|
explicit ArrayRef(T& one) : data(&one), length(1) {}
|
||||||
|
ArrayRef(T* data, size_t length) : data(data), length(length) {}
|
||||||
|
ArrayRef(T* begin, T* end) : data(begin), length(end - begin) {}
|
||||||
|
template <size_t N>
|
||||||
|
constexpr explicit ArrayRef(T (&arr)[N]) : data(arr), length(N) {}
|
||||||
|
template <size_t N>
|
||||||
|
constexpr explicit ArrayRef(std::array<T, N> arr) : data(arr.data()), length(arr.size()) {}
|
||||||
|
explicit ArrayRef(std::vector<T> vec) : data(vec.data()), length(vec.size()) {}
|
||||||
|
|
||||||
|
private:
|
||||||
|
T* data = nullptr;
|
||||||
|
size_t length = 0;
|
||||||
|
};
|
||||||
|
} // namespace aurora
|
||||||
|
|
||||||
namespace metaforce {
|
namespace metaforce {
|
||||||
extern hecl::CVar* g_disableLighting;
|
extern hecl::CVar* g_disableLighting;
|
||||||
class CLight;
|
class CLight;
|
||||||
|
@ -91,21 +153,7 @@ enum class ERglAlphaFunc {
|
||||||
|
|
||||||
enum class ERglAlphaOp { And = 0, Or = 1, Xor = 2, XNor = 3 };
|
enum class ERglAlphaOp { And = 0, Or = 1, Xor = 2, XNor = 3 };
|
||||||
|
|
||||||
enum class ERglFogMode : uint32_t {
|
using ERglFogMode = aurora::shaders::FogMode;
|
||||||
None = 0x00,
|
|
||||||
|
|
||||||
PerspLin = 0x02,
|
|
||||||
PerspExp = 0x04,
|
|
||||||
PerspExp2 = 0x05,
|
|
||||||
PerspRevExp = 0x06,
|
|
||||||
PerspRevExp2 = 0x07,
|
|
||||||
|
|
||||||
OrthoLin = 0x0A,
|
|
||||||
OrthoExp = 0x0C,
|
|
||||||
OrthoExp2 = 0x0D,
|
|
||||||
OrthoRevExp = 0x0E,
|
|
||||||
OrthoRevExp2 = 0x0F
|
|
||||||
};
|
|
||||||
|
|
||||||
struct SViewport {
|
struct SViewport {
|
||||||
u32 x0_left;
|
u32 x0_left;
|
||||||
|
@ -145,12 +193,12 @@ struct SClipScreenRect {
|
||||||
, x20_uvYMin(uvYMin)
|
, x20_uvYMin(uvYMin)
|
||||||
, x24_uvYMax(uvYMax) {}
|
, x24_uvYMax(uvYMax) {}
|
||||||
|
|
||||||
SClipScreenRect(const boo::SWindowRect& rect) {
|
SClipScreenRect(const aurora::shaders::ClipRect& rect) {
|
||||||
x4_left = rect.location[0];
|
x4_left = rect.x;
|
||||||
x8_top = rect.location[1];
|
x8_top = rect.y;
|
||||||
xc_width = rect.size[0];
|
xc_width = rect.width;
|
||||||
x10_height = rect.size[1];
|
x10_height = rect.height;
|
||||||
x14_dstWidth = rect.size[0];
|
x14_dstWidth = rect.width;
|
||||||
}
|
}
|
||||||
|
|
||||||
SClipScreenRect(const SViewport& vp) {
|
SClipScreenRect(const SViewport& vp) {
|
||||||
|
@ -243,13 +291,14 @@ public:
|
||||||
float x18_far;
|
float x18_far;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CFogState {
|
using CFogState = aurora::shaders::FogState;
|
||||||
zeus::CColor m_color;
|
// struct CFogState {
|
||||||
float m_A = 0.f;
|
// zeus::CColor m_color;
|
||||||
float m_B = 0.5f;
|
// float m_A = 0.f;
|
||||||
float m_C = 0.f;
|
// float m_B = 0.5f;
|
||||||
ERglFogMode m_mode;
|
// float m_C = 0.f;
|
||||||
};
|
// ERglFogMode m_mode;
|
||||||
|
// };
|
||||||
|
|
||||||
static CProjectionState g_Proj;
|
static CProjectionState g_Proj;
|
||||||
static zeus::CVector2f g_CachedDepthRange;
|
static zeus::CVector2f g_CachedDepthRange;
|
||||||
|
@ -321,73 +370,78 @@ public:
|
||||||
static u32 GetFPS() { return g_Framerate; }
|
static u32 GetFPS() { return g_Framerate; }
|
||||||
static void UpdateFPSCounter();
|
static void UpdateFPSCounter();
|
||||||
|
|
||||||
static boo::IGraphicsDataFactory::Platform g_BooPlatform;
|
// static boo::IGraphicsDataFactory::Platform g_BooPlatform;
|
||||||
static const char* g_BooPlatformName;
|
// static const char* g_BooPlatformName;
|
||||||
static boo::IGraphicsDataFactory* g_BooFactory;
|
// static boo::IGraphicsDataFactory* g_BooFactory;
|
||||||
static boo::IGraphicsCommandQueue* g_BooMainCommandQueue;
|
// static boo::IGraphicsCommandQueue* g_BooMainCommandQueue;
|
||||||
static boo::ObjToken<boo::ITextureR> g_SpareTexture;
|
// static boo::ObjToken<boo::ITextureR> g_SpareTexture;
|
||||||
|
|
||||||
static const std::array<zeus::CMatrix3f, 6> skCubeBasisMats;
|
static const std::array<zeus::CMatrix3f, 6> skCubeBasisMats;
|
||||||
|
|
||||||
static void InitializeBoo(boo::IGraphicsDataFactory* factory, boo::IGraphicsCommandQueue* cc,
|
// static void InitializeBoo(boo::IGraphicsDataFactory* factory, boo::IGraphicsCommandQueue* cc,
|
||||||
const boo::ObjToken<boo::ITextureR>& spareTex) {
|
// const boo::ObjToken<boo::ITextureR>& spareTex) {
|
||||||
g_BooPlatform = factory->platform();
|
// g_BooPlatform = factory->platform();
|
||||||
g_BooPlatformName = factory->platformName();
|
// g_BooPlatformName = factory->platformName();
|
||||||
g_BooFactory = factory;
|
// g_BooFactory = factory;
|
||||||
g_BooMainCommandQueue = cc;
|
// g_BooMainCommandQueue = cc;
|
||||||
g_SpareTexture = spareTex;
|
// g_SpareTexture = spareTex;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
// static void ShutdownBoo() {
|
||||||
|
// g_BooFactory = nullptr;
|
||||||
|
// g_BooMainCommandQueue = nullptr;
|
||||||
|
// g_SpareTexture.reset();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// static const char* PlatformName() { return g_BooPlatformName; }
|
||||||
|
|
||||||
static void ShutdownBoo() {
|
// static void CommitResources(const boo::FactoryCommitFunc& commitFunc __BooTraceArgs) {
|
||||||
g_BooFactory = nullptr;
|
// g_BooFactory->commitTransaction(commitFunc __BooTraceArgsUse);
|
||||||
g_BooMainCommandQueue = nullptr;
|
// }
|
||||||
g_SpareTexture.reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
static const char* PlatformName() { return g_BooPlatformName; }
|
// static bool g_commitAsLazy;
|
||||||
|
// static void SetCommitResourcesAsLazy(bool newStatus) {
|
||||||
|
// if (newStatus != g_commitAsLazy) {
|
||||||
static bool g_commitAsLazy;
|
// g_commitAsLazy = newStatus;
|
||||||
static void SetCommitResourcesAsLazy(bool newStatus) {
|
// if (!newStatus && g_BooFactory) {
|
||||||
if (newStatus != g_commitAsLazy) {
|
// g_BooFactory->commitPendingTransaction();
|
||||||
g_commitAsLazy = newStatus;
|
// }
|
||||||
if (!newStatus && g_BooFactory) {
|
// }
|
||||||
g_BooFactory->commitPendingTransaction();
|
// }
|
||||||
}
|
//
|
||||||
}
|
// static void CommitResources(const boo::FactoryCommitFunc& commitFunc __BooTraceArgs) {
|
||||||
}
|
// CommitResources(commitFunc __BooTraceArgsUse, g_commitAsLazy);
|
||||||
|
// }
|
||||||
static void CommitResources(const boo::FactoryCommitFunc& commitFunc __BooTraceArgs) {
|
//
|
||||||
CommitResources(commitFunc __BooTraceArgsUse, g_commitAsLazy);
|
// static void CommitResources(const boo::FactoryCommitFunc& commitFunc __BooTraceArgs, bool lazy) {
|
||||||
}
|
// if (!g_BooFactory) {
|
||||||
|
// return;
|
||||||
static void CommitResources(const boo::FactoryCommitFunc& commitFunc __BooTraceArgs, bool lazy) {
|
// }
|
||||||
if (!g_BooFactory) {
|
// if (lazy) {
|
||||||
return;
|
// g_BooFactory->lazyCommitTransaction(commitFunc __BooTraceArgsUse);
|
||||||
}
|
// } else {
|
||||||
if (lazy) {
|
// g_BooFactory->commitTransaction(commitFunc __BooTraceArgsUse);
|
||||||
g_BooFactory->lazyCommitTransaction(commitFunc __BooTraceArgsUse);
|
// }
|
||||||
} else {
|
// }
|
||||||
g_BooFactory->commitTransaction(commitFunc __BooTraceArgsUse);
|
//
|
||||||
}
|
// static void SetShaderDataBinding(const boo::ObjToken<boo::IShaderDataBinding>& binding) {
|
||||||
}
|
// g_BooMainCommandQueue->setShaderDataBinding(binding);
|
||||||
|
// }
|
||||||
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) {
|
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};
|
aurora::shaders::resolve_color({rect.x4_left, rect.x8_top, rect.xc_width, rect.x10_height}, bindIdx, clearDepth);
|
||||||
g_BooMainCommandQueue->resolveBindTexture(g_SpareTexture, wrect, true, bindIdx, true, false, clearDepth);
|
// 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);
|
||||||
}
|
}
|
||||||
static void ResolveSpareDepth(const SClipScreenRect& rect, int bindIdx = 0) {
|
static void ResolveSpareDepth(const SClipScreenRect& rect, int bindIdx = 0) {
|
||||||
boo::SWindowRect wrect = {rect.x4_left, rect.x8_top, rect.xc_width, rect.x10_height};
|
aurora::shaders::resolve_depth({rect.x4_left, rect.x8_top, rect.xc_width, rect.x10_height}, bindIdx);
|
||||||
g_BooMainCommandQueue->resolveBindTexture(g_SpareTexture, wrect, true, bindIdx, false, true);
|
// 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);
|
||||||
}
|
}
|
||||||
static void DrawInstances(size_t start, size_t count, size_t instCount, size_t startInst = 0) {
|
// static void DrawInstances(size_t start, size_t count, size_t instCount, size_t startInst = 0) {
|
||||||
g_BooMainCommandQueue->drawInstances(start, count, instCount, startInst);
|
// g_BooMainCommandQueue->drawInstances(start, count, instCount, startInst);
|
||||||
}
|
// }
|
||||||
static void DrawArray(size_t start, size_t count) { g_BooMainCommandQueue->draw(start, count); }
|
// 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 void DrawArrayIndexed(size_t start, size_t count) { g_BooMainCommandQueue->drawIndexed(start, count); }
|
||||||
|
|
||||||
static const CTevCombiners::CTevPass sTevPass805a564c;
|
static const CTevCombiners::CTevPass sTevPass805a564c;
|
||||||
static const CTevCombiners::CTevPass sTevPass805a5698;
|
static const CTevCombiners::CTevPass sTevPass805a5698;
|
||||||
|
@ -441,7 +495,7 @@ public:
|
||||||
m_vec.emplace_back(std::forward<_Args>(args)...);
|
m_vec.emplace_back(std::forward<_Args>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Draw() const { CGraphics::DrawArray(m_start, m_vec.size() - m_start); }
|
// void Draw() const { CGraphics::DrawArray(m_start, m_vec.size() - m_start); }
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef BOO_GRAPHICS_DEBUG_GROUPS
|
#ifdef BOO_GRAPHICS_DEBUG_GROUPS
|
||||||
|
|
|
@ -11,48 +11,16 @@ void CLineRenderer::Initialize() { CLineRendererShaders::Initialize(); }
|
||||||
|
|
||||||
void CLineRenderer::Shutdown() {
|
void CLineRenderer::Shutdown() {
|
||||||
CLineRendererShaders::Shutdown();
|
CLineRendererShaders::Shutdown();
|
||||||
s_vertPoolTex.doDestroy();
|
// s_vertPoolTex.doDestroy();
|
||||||
s_vertPoolNoTex.doDestroy();
|
// s_vertPoolNoTex.doDestroy();
|
||||||
s_uniformPool.doDestroy();
|
// s_uniformPool.doDestroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
hecl::VertexBufferPool<CLineRenderer::SDrawVertTex> CLineRenderer::s_vertPoolTex = {};
|
//hecl::VertexBufferPool<CLineRenderer::SDrawVertTex> CLineRenderer::s_vertPoolTex = {};
|
||||||
hecl::VertexBufferPool<CLineRenderer::SDrawVertNoTex> CLineRenderer::s_vertPoolNoTex = {};
|
//hecl::VertexBufferPool<CLineRenderer::SDrawVertNoTex> CLineRenderer::s_vertPoolNoTex = {};
|
||||||
hecl::UniformBufferPool<CLineRenderer::SDrawUniform> CLineRenderer::s_uniformPool = {};
|
//hecl::UniformBufferPool<CLineRenderer::SDrawUniform> CLineRenderer::s_uniformPool = {};
|
||||||
|
|
||||||
CLineRenderer::CLineRenderer(boo::IGraphicsDataFactory::Context& ctx, EPrimitiveMode mode, u32 maxVerts,
|
CLineRenderer::CLineRenderer(EPrimitiveMode mode, u32 maxVerts, const std::shared_ptr<aurora::TextureHandle>& texture,
|
||||||
const boo::ObjToken<boo::ITexture>& texture, bool additive, bool zTest, bool zGEqual)
|
|
||||||
: m_mode(mode), m_maxVerts(maxVerts) {
|
|
||||||
OPTICK_EVENT();
|
|
||||||
if (maxVerts < 2) {
|
|
||||||
LineRendererLog.report(logvisor::Fatal, FMT_STRING("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);
|
|
||||||
|
|
||||||
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)
|
bool additive, bool zTest, bool zGEqual)
|
||||||
: m_mode(mode), m_maxVerts(maxVerts) {
|
: m_mode(mode), m_maxVerts(maxVerts) {
|
||||||
OPTICK_EVENT();
|
OPTICK_EVENT();
|
||||||
|
@ -73,22 +41,22 @@ CLineRenderer::CLineRenderer(EPrimitiveMode mode, u32 maxVerts, const boo::ObjTo
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (texture) {
|
// if (texture) {
|
||||||
m_vertBufTex = s_vertPoolTex.allocateBlock(CGraphics::g_BooFactory, maxTriVerts);
|
// m_vertBufTex = s_vertPoolTex.allocateBlock(CGraphics::g_BooFactory, maxTriVerts);
|
||||||
} else {
|
// } else {
|
||||||
m_vertBufNoTex = s_vertPoolNoTex.allocateBlock(CGraphics::g_BooFactory, maxTriVerts);
|
// m_vertBufNoTex = s_vertPoolNoTex.allocateBlock(CGraphics::g_BooFactory, maxTriVerts);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
m_uniformBuf = s_uniformPool.allocateBlock(CGraphics::g_BooFactory);
|
// m_uniformBuf = s_uniformPool.allocateBlock(CGraphics::g_BooFactory);
|
||||||
|
//
|
||||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
// CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
||||||
CLineRendererShaders::BuildShaderDataBinding(ctx, *this, texture, additive, zTest, zGEqual);
|
// CLineRendererShaders::BuildShaderDataBinding(ctx, *this, texture, additive, zTest, zGEqual);
|
||||||
return true;
|
// return true;
|
||||||
} BooTrace);
|
// } BooTrace);
|
||||||
}
|
}
|
||||||
|
|
||||||
rstl::reserved_vector<CLineRenderer::SDrawVertTex, 1024> CLineRenderer::g_StaticLineVertsTex = {};
|
//rstl::reserved_vector<CLineRenderer::SDrawVertTex, 1024> CLineRenderer::g_StaticLineVertsTex = {};
|
||||||
rstl::reserved_vector<CLineRenderer::SDrawVertNoTex, 1024> CLineRenderer::g_StaticLineVertsNoTex = {};
|
//rstl::reserved_vector<CLineRenderer::SDrawVertNoTex, 1024> CLineRenderer::g_StaticLineVertsNoTex = {};
|
||||||
|
|
||||||
static bool IntersectLines(const zeus::CVector2f& pa1, const zeus::CVector2f& pa2, const zeus::CVector2f& pb1,
|
static bool IntersectLines(const zeus::CVector2f& pa1, const zeus::CVector2f& pa2, const zeus::CVector2f& pb1,
|
||||||
const zeus::CVector2f& pb2, zeus::CVector3f& intersect) {
|
const zeus::CVector2f& pb2, zeus::CVector3f& intersect) {
|
||||||
|
@ -106,15 +74,15 @@ static bool IntersectLines(const zeus::CVector2f& pa1, const zeus::CVector2f& pa
|
||||||
void CLineRenderer::Reset() {
|
void CLineRenderer::Reset() {
|
||||||
m_nextVert = 0;
|
m_nextVert = 0;
|
||||||
m_final = false;
|
m_final = false;
|
||||||
if (m_textured)
|
// if (m_textured)
|
||||||
g_StaticLineVertsTex.clear();
|
// g_StaticLineVertsTex.clear();
|
||||||
else
|
// else
|
||||||
g_StaticLineVertsNoTex.clear();
|
// g_StaticLineVertsNoTex.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLineRenderer::AddVertex(const zeus::CVector3f& position, const zeus::CColor& color, float width,
|
void CLineRenderer::AddVertex(const zeus::CVector3f& position, const zeus::CColor& color, float width,
|
||||||
const zeus::CVector2f& uv) {
|
const zeus::CVector2f& uv) {
|
||||||
if (m_final || !m_shaderBind[0] || m_nextVert >= m_maxVerts)
|
if (m_final /*|| !m_shaderBind[0]*/ || m_nextVert >= m_maxVerts)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
float adjWidth = width / 480.f;
|
float adjWidth = width / 480.f;
|
||||||
|
@ -150,13 +118,13 @@ void CLineRenderer::AddVertex(const zeus::CVector3f& position, const zeus::CColo
|
||||||
if (m_textured) {
|
if (m_textured) {
|
||||||
if (m_mode == EPrimitiveMode::Lines) {
|
if (m_mode == EPrimitiveMode::Lines) {
|
||||||
if (m_nextVert & 1) {
|
if (m_nextVert & 1) {
|
||||||
g_StaticLineVertsTex.push_back(g_StaticLineVertsTex.back());
|
// 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.push_back({zeus::CVector4f::ToClip(m_lastPos + dvb, m_lastW), m_lastColor, m_lastUV});
|
||||||
g_StaticLineVertsTex.push_back(g_StaticLineVertsTex.back());
|
// 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.push_back({zeus::CVector4f::ToClip(m_lastPos - dvb, m_lastW), m_lastColor, m_lastUV});
|
||||||
} else {
|
} 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 - dva, m_lastW), m_lastColor, m_lastUV});
|
// g_StaticLineVertsTex.push_back({zeus::CVector4f::ToClip(m_lastPos - dva, m_lastW), m_lastColor, m_lastUV});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
zeus::CVector3f intersect1;
|
zeus::CVector3f intersect1;
|
||||||
|
@ -174,25 +142,25 @@ void CLineRenderer::AddVertex(const zeus::CVector3f& position, const zeus::CColo
|
||||||
if (good1 && good2) {
|
if (good1 && good2) {
|
||||||
intersect1.z() = float(m_lastPos.z());
|
intersect1.z() = float(m_lastPos.z());
|
||||||
intersect2.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(intersect1, m_lastW), m_lastColor, m_lastUV});
|
||||||
g_StaticLineVertsTex.push_back({zeus::CVector4f::ToClip(intersect2, m_lastW), m_lastColor, m_lastUV});
|
// g_StaticLineVertsTex.push_back({zeus::CVector4f::ToClip(intersect2, m_lastW), m_lastColor, m_lastUV});
|
||||||
} else {
|
} 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 - 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.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});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (m_mode == EPrimitiveMode::Lines) {
|
if (m_mode == EPrimitiveMode::Lines) {
|
||||||
if (m_nextVert & 1) {
|
if (m_nextVert & 1) {
|
||||||
g_StaticLineVertsNoTex.push_back(g_StaticLineVertsNoTex.back());
|
// g_StaticLineVertsNoTex.push_back(g_StaticLineVertsNoTex.back());
|
||||||
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.push_back(g_StaticLineVertsNoTex.back());
|
// g_StaticLineVertsNoTex.push_back(g_StaticLineVertsNoTex.back());
|
||||||
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});
|
||||||
} else {
|
} 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 - dva, m_lastW), m_lastColor});
|
// g_StaticLineVertsNoTex.push_back({zeus::CVector4f::ToClip(m_lastPos - dva, m_lastW), m_lastColor});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
zeus::CVector3f intersect1;
|
zeus::CVector3f intersect1;
|
||||||
|
@ -210,13 +178,13 @@ void CLineRenderer::AddVertex(const zeus::CVector3f& position, const zeus::CColo
|
||||||
if (good1 && good2) {
|
if (good1 && good2) {
|
||||||
intersect1.z() = float(m_lastPos.z());
|
intersect1.z() = float(m_lastPos.z());
|
||||||
intersect2.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(intersect1, m_lastW), m_lastColor});
|
||||||
g_StaticLineVertsNoTex.push_back({zeus::CVector4f::ToClip(intersect2, m_lastW), m_lastColor});
|
// g_StaticLineVertsNoTex.push_back({zeus::CVector4f::ToClip(intersect2, m_lastW), m_lastColor});
|
||||||
} else {
|
} 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 - 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.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});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -227,11 +195,11 @@ void CLineRenderer::AddVertex(const zeus::CVector3f& position, const zeus::CColo
|
||||||
dv = dv.normalized().perpendicularVector() * m_lastWidth;
|
dv = dv.normalized().perpendicularVector() * m_lastWidth;
|
||||||
dv.x() /= CGraphics::g_ProjAspect;
|
dv.x() /= CGraphics::g_ProjAspect;
|
||||||
if (m_textured) {
|
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.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});
|
||||||
} else {
|
} 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.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});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -278,25 +246,25 @@ void CLineRenderer::Render(bool alphaWrite, const zeus::CColor& moduColor) {
|
||||||
if (good1 && good2) {
|
if (good1 && good2) {
|
||||||
intersect1.z() = float(m_lastPos.z());
|
intersect1.z() = float(m_lastPos.z());
|
||||||
intersect2.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(intersect1, m_lastW), m_lastColor, m_lastUV});
|
||||||
g_StaticLineVertsTex.push_back({zeus::CVector4f::ToClip(intersect2, m_lastW), m_lastColor, m_lastUV});
|
// g_StaticLineVertsTex.push_back({zeus::CVector4f::ToClip(intersect2, m_lastW), m_lastColor, m_lastUV});
|
||||||
} else {
|
} 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 - 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.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});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (good1 && good2) {
|
if (good1 && good2) {
|
||||||
intersect1.z() = float(m_lastPos.z());
|
intersect1.z() = float(m_lastPos.z());
|
||||||
intersect2.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(intersect1, m_lastW), m_lastColor});
|
||||||
g_StaticLineVertsNoTex.push_back({zeus::CVector4f::ToClip(intersect2, m_lastW), m_lastColor});
|
// g_StaticLineVertsNoTex.push_back({zeus::CVector4f::ToClip(intersect2, m_lastW), m_lastColor});
|
||||||
} else {
|
} 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 - 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.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});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -329,25 +297,25 @@ void CLineRenderer::Render(bool alphaWrite, const zeus::CColor& moduColor) {
|
||||||
if (good1 && good2) {
|
if (good1 && good2) {
|
||||||
intersect1.z() = float(m_firstPos.z());
|
intersect1.z() = float(m_firstPos.z());
|
||||||
intersect2.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(intersect1, m_lastW), m_lastColor, m_lastUV});
|
||||||
g_StaticLineVertsTex.push_back({zeus::CVector4f::ToClip(intersect2, m_lastW), m_lastColor, m_lastUV});
|
// g_StaticLineVertsTex.push_back({zeus::CVector4f::ToClip(intersect2, m_lastW), m_lastColor, m_lastUV});
|
||||||
} else {
|
} 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 - 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.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});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (good1 && good2) {
|
if (good1 && good2) {
|
||||||
intersect1.z() = float(m_firstPos.z());
|
intersect1.z() = float(m_firstPos.z());
|
||||||
intersect2.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(intersect1, m_lastW), m_lastColor});
|
||||||
g_StaticLineVertsNoTex.push_back({zeus::CVector4f::ToClip(intersect2, m_lastW), m_lastColor});
|
// g_StaticLineVertsNoTex.push_back({zeus::CVector4f::ToClip(intersect2, m_lastW), m_lastColor});
|
||||||
} else {
|
} 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 - 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.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});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -360,14 +328,14 @@ void CLineRenderer::Render(bool alphaWrite, const zeus::CColor& moduColor) {
|
||||||
if (m_textured) {
|
if (m_textured) {
|
||||||
if (m_mode == EPrimitiveMode::Lines && (m_nextVert & 1)) {
|
if (m_mode == EPrimitiveMode::Lines && (m_nextVert & 1)) {
|
||||||
} else {
|
} 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.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});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (m_mode == EPrimitiveMode::Lines && (m_nextVert & 1)) {
|
if (m_mode == EPrimitiveMode::Lines && (m_nextVert & 1)) {
|
||||||
} else {
|
} 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.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});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -375,21 +343,21 @@ void CLineRenderer::Render(bool alphaWrite, const zeus::CColor& moduColor) {
|
||||||
m_final = true;
|
m_final = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_uniformBuf.access() = SDrawUniform{moduColor, CGraphics::g_Fog};
|
// m_uniformBuf.access() = SDrawUniform{moduColor, CGraphics::g_Fog};
|
||||||
if (m_textured) {
|
// if (m_textured) {
|
||||||
if (!g_StaticLineVertsTex.empty()) {
|
// if (!g_StaticLineVertsTex.empty()) {
|
||||||
memmove(m_vertBufTex.access(), g_StaticLineVertsTex.data(), sizeof(SDrawVertTex) * g_StaticLineVertsTex.size());
|
// memmove(m_vertBufTex.access(), g_StaticLineVertsTex.data(), sizeof(SDrawVertTex) * g_StaticLineVertsTex.size());
|
||||||
CGraphics::SetShaderDataBinding(m_shaderBind[alphaWrite]);
|
// CGraphics::SetShaderDataBinding(m_shaderBind[alphaWrite]);
|
||||||
CGraphics::DrawArray(0, g_StaticLineVertsTex.size());
|
// CGraphics::DrawArray(0, g_StaticLineVertsTex.size());
|
||||||
}
|
// }
|
||||||
} else {
|
// } else {
|
||||||
if (!g_StaticLineVertsNoTex.empty()) {
|
// if (!g_StaticLineVertsNoTex.empty()) {
|
||||||
memmove(m_vertBufNoTex.access(), g_StaticLineVertsNoTex.data(),
|
// memmove(m_vertBufNoTex.access(), g_StaticLineVertsNoTex.data(),
|
||||||
sizeof(SDrawVertNoTex) * g_StaticLineVertsNoTex.size());
|
// sizeof(SDrawVertNoTex) * g_StaticLineVertsNoTex.size());
|
||||||
CGraphics::SetShaderDataBinding(m_shaderBind[alphaWrite]);
|
// CGraphics::SetShaderDataBinding(m_shaderBind[alphaWrite]);
|
||||||
CGraphics::DrawArray(0, g_StaticLineVertsNoTex.size());
|
// CGraphics::DrawArray(0, g_StaticLineVertsNoTex.size());
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace metaforce
|
} // namespace metaforce
|
||||||
|
|
|
@ -6,10 +6,10 @@
|
||||||
#include "Runtime/rstl.hpp"
|
#include "Runtime/rstl.hpp"
|
||||||
#include "Runtime/Graphics/CGraphics.hpp"
|
#include "Runtime/Graphics/CGraphics.hpp"
|
||||||
|
|
||||||
#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
//#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
||||||
|
|
||||||
#include <hecl/UniformBufferPool.hpp>
|
//#include <hecl/UniformBufferPool.hpp>
|
||||||
#include <hecl/VertexBufferPool.hpp>
|
//#include <hecl/VertexBufferPool.hpp>
|
||||||
|
|
||||||
#include <zeus/CColor.hpp>
|
#include <zeus/CColor.hpp>
|
||||||
#include <zeus/CVector2f.hpp>
|
#include <zeus/CVector2f.hpp>
|
||||||
|
@ -59,22 +59,20 @@ private:
|
||||||
float m_lastWidth;
|
float m_lastWidth;
|
||||||
float m_lastW;
|
float m_lastW;
|
||||||
|
|
||||||
static rstl::reserved_vector<SDrawVertTex, 1024> g_StaticLineVertsTex;
|
// static rstl::reserved_vector<SDrawVertTex, 1024> g_StaticLineVertsTex;
|
||||||
static rstl::reserved_vector<SDrawVertNoTex, 1024> g_StaticLineVertsNoTex;
|
// static rstl::reserved_vector<SDrawVertNoTex, 1024> g_StaticLineVertsNoTex;
|
||||||
|
|
||||||
static hecl::VertexBufferPool<SDrawVertTex> s_vertPoolTex;
|
// static hecl::VertexBufferPool<SDrawVertTex> s_vertPoolTex;
|
||||||
static hecl::VertexBufferPool<SDrawVertNoTex> s_vertPoolNoTex;
|
// static hecl::VertexBufferPool<SDrawVertNoTex> s_vertPoolNoTex;
|
||||||
static hecl::UniformBufferPool<SDrawUniform> s_uniformPool;
|
// static hecl::UniformBufferPool<SDrawUniform> s_uniformPool;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
hecl::VertexBufferPool<SDrawVertTex>::Token m_vertBufTex;
|
// hecl::VertexBufferPool<SDrawVertTex>::Token m_vertBufTex;
|
||||||
hecl::VertexBufferPool<SDrawVertNoTex>::Token m_vertBufNoTex;
|
// hecl::VertexBufferPool<SDrawVertNoTex>::Token m_vertBufNoTex;
|
||||||
hecl::UniformBufferPool<SDrawUniform>::Token m_uniformBuf;
|
// hecl::UniformBufferPool<SDrawUniform>::Token m_uniformBuf;
|
||||||
std::array<boo::ObjToken<boo::IShaderDataBinding>, 2> m_shaderBind;
|
// std::array<boo::ObjToken<boo::IShaderDataBinding>, 2> m_shaderBind;
|
||||||
|
|
||||||
CLineRenderer(boo::IGraphicsDataFactory::Context& ctx, EPrimitiveMode mode, u32 maxVerts,
|
CLineRenderer(EPrimitiveMode mode, u32 maxVerts, const std::shared_ptr<aurora::TextureHandle>& texture, bool additive,
|
||||||
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);
|
bool zTest = false, bool zGEqual = false);
|
||||||
CLineRenderer(CLineRenderer&&) = default;
|
CLineRenderer(CLineRenderer&&) = default;
|
||||||
|
|
||||||
|
@ -83,11 +81,11 @@ public:
|
||||||
const zeus::CVector2f& uv = zeus::skZero2f);
|
const zeus::CVector2f& uv = zeus::skZero2f);
|
||||||
void Render(bool alphaWrite = false, const zeus::CColor& moduColor = zeus::skWhite);
|
void Render(bool alphaWrite = false, const zeus::CColor& moduColor = zeus::skWhite);
|
||||||
|
|
||||||
static void UpdateBuffers() {
|
// static void UpdateBuffers() {
|
||||||
s_vertPoolTex.updateBuffers();
|
// s_vertPoolTex.updateBuffers();
|
||||||
s_vertPoolNoTex.updateBuffers();
|
// s_vertPoolNoTex.updateBuffers();
|
||||||
s_uniformPool.updateBuffers();
|
// s_uniformPool.updateBuffers();
|
||||||
}
|
// }
|
||||||
|
|
||||||
static void Initialize();
|
static void Initialize();
|
||||||
static void Shutdown();
|
static void Shutdown();
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
set(GRAPHICS_SOURCES
|
set(GRAPHICS_SOURCES
|
||||||
IRenderer.hpp
|
IRenderer.hpp
|
||||||
IWeaponRenderer.hpp IWeaponRenderer.cpp
|
IWeaponRenderer.hpp IWeaponRenderer.cpp
|
||||||
|
CCubeModel.cpp CCubeModel.hpp
|
||||||
CBooRenderer.hpp CBooRenderer.cpp
|
CBooRenderer.hpp CBooRenderer.cpp
|
||||||
CDrawable.hpp
|
CDrawable.hpp
|
||||||
CDrawablePlaneObject.hpp
|
CDrawablePlaneObject.hpp
|
||||||
|
|
|
@ -27,7 +27,7 @@ class CMetroidModelInstance {
|
||||||
std::vector<CBooSurface> m_surfaces;
|
std::vector<CBooSurface> m_surfaces;
|
||||||
std::unique_ptr<CBooModel> m_instance;
|
std::unique_ptr<CBooModel> m_instance;
|
||||||
hecl::HMDLMeta m_hmdlMeta;
|
hecl::HMDLMeta m_hmdlMeta;
|
||||||
std::unordered_map<int, CModelShaders::ShaderPipelines> m_shaders;
|
// std::unordered_map<int, CModelShaders::ShaderPipelines> m_shaders;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CMetroidModelInstance() = default;
|
CMetroidModelInstance() = default;
|
||||||
|
@ -39,7 +39,7 @@ public:
|
||||||
m_surfaces.clear();
|
m_surfaces.clear();
|
||||||
m_instance.reset();
|
m_instance.reset();
|
||||||
m_hmdlMeta = {};
|
m_hmdlMeta = {};
|
||||||
m_shaders.clear();
|
// m_shaders.clear();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -9,11 +9,10 @@
|
||||||
#include "DataSpec/DNAMP1/CMDLMaterials.hpp"
|
#include "DataSpec/DNAMP1/CMDLMaterials.hpp"
|
||||||
#include "Runtime/CFactoryMgr.hpp"
|
#include "Runtime/CFactoryMgr.hpp"
|
||||||
#include "Runtime/CToken.hpp"
|
#include "Runtime/CToken.hpp"
|
||||||
#include "Runtime/RetroTypes.hpp"
|
|
||||||
#include "Runtime/Graphics/CTexture.hpp"
|
#include "Runtime/Graphics/CTexture.hpp"
|
||||||
#include "Runtime/Graphics/Shaders/CModelShaders.hpp"
|
#include "Runtime/Graphics/Shaders/CModelShaders.hpp"
|
||||||
|
#include "Runtime/RetroTypes.hpp"
|
||||||
|
|
||||||
#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
|
||||||
#include <hecl/HMDLMeta.hpp>
|
#include <hecl/HMDLMeta.hpp>
|
||||||
#include <zeus/CAABox.hpp>
|
#include <zeus/CAABox.hpp>
|
||||||
#include <zeus/CColor.hpp>
|
#include <zeus/CColor.hpp>
|
||||||
|
@ -80,42 +79,42 @@ struct CBooSurface {
|
||||||
|
|
||||||
using MaterialSet = DataSpec::DNAMP1::HMDLMaterialSet;
|
using MaterialSet = DataSpec::DNAMP1::HMDLMaterialSet;
|
||||||
|
|
||||||
struct GeometryUniformLayout {
|
//struct GeometryUniformLayout {
|
||||||
mutable std::vector<boo::ObjToken<boo::IGraphicsBufferD>> m_sharedBuffer;
|
// mutable std::vector<boo::ObjToken<boo::IGraphicsBufferD>> m_sharedBuffer;
|
||||||
size_t m_geomBufferSize = 0;
|
// size_t m_geomBufferSize = 0;
|
||||||
size_t m_skinBankCount = 0;
|
// size_t m_skinBankCount = 0;
|
||||||
size_t m_weightVecCount = 0;
|
// size_t m_weightVecCount = 0;
|
||||||
|
//
|
||||||
std::vector<size_t> m_skinOffs;
|
// std::vector<size_t> m_skinOffs;
|
||||||
std::vector<size_t> m_skinSizes;
|
// std::vector<size_t> m_skinSizes;
|
||||||
|
//
|
||||||
std::vector<size_t> m_uvOffs;
|
// std::vector<size_t> m_uvOffs;
|
||||||
std::vector<size_t> m_uvSizes;
|
// std::vector<size_t> m_uvSizes;
|
||||||
|
//
|
||||||
GeometryUniformLayout(const CModel* model, const MaterialSet* matSet);
|
// GeometryUniformLayout(const CModel* model, const MaterialSet* matSet);
|
||||||
void Update(const CModelFlags& flags, const CSkinRules* cskr, const CPoseAsTransforms* pose,
|
// void Update(const CModelFlags& flags, const CSkinRules* cskr, const CPoseAsTransforms* pose,
|
||||||
const MaterialSet* matSet, const boo::ObjToken<boo::IGraphicsBufferD>& buf,
|
// const MaterialSet* matSet, const boo::ObjToken<boo::IGraphicsBufferD>& buf,
|
||||||
const CBooModel* parent) const;
|
// const CBooModel* parent) const;
|
||||||
|
//
|
||||||
void ReserveSharedBuffers(boo::IGraphicsDataFactory::Context& ctx, int size);
|
// void ReserveSharedBuffers(boo::IGraphicsDataFactory::Context& ctx, int size);
|
||||||
boo::ObjToken<boo::IGraphicsBufferD> GetSharedBuffer(int idx) const;
|
// boo::ObjToken<boo::IGraphicsBufferD> GetSharedBuffer(int idx) const;
|
||||||
};
|
//};
|
||||||
|
|
||||||
struct SShader {
|
struct SShader {
|
||||||
std::unordered_map<CAssetId, TCachedToken<CTexture>> x0_textures;
|
std::unordered_map<CAssetId, TCachedToken<CTexture>> x0_textures;
|
||||||
std::unordered_map<int, CModelShaders::ShaderPipelines> m_shaders;
|
// std::unordered_map<int, CModelShaders::ShaderPipelines> m_shaders;
|
||||||
MaterialSet m_matSet;
|
MaterialSet m_matSet;
|
||||||
std::optional<GeometryUniformLayout> m_geomLayout;
|
// std::optional<GeometryUniformLayout> m_geomLayout;
|
||||||
int m_matSetIdx;
|
int m_matSetIdx;
|
||||||
explicit SShader(int idx) : m_matSetIdx(idx) {
|
explicit SShader(int idx) : m_matSetIdx(idx) {
|
||||||
x0_textures.clear();
|
x0_textures.clear();
|
||||||
m_shaders.clear();
|
// m_shaders.clear();
|
||||||
}
|
}
|
||||||
void InitializeLayout(const CModel* model) { m_geomLayout.emplace(model, &m_matSet); }
|
// void InitializeLayout(const CModel* model) { m_geomLayout.emplace(model, &m_matSet); }
|
||||||
void UnlockTextures();
|
void UnlockTextures();
|
||||||
CModelShaders::ShaderPipelines BuildShader(const hecl::HMDLMeta& meta, const MaterialSet::Material& mat);
|
// 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, std::unordered_map<int, CModelShaders::ShaderPipelines>& shaders);
|
||||||
void BuildShaders(const hecl::HMDLMeta& meta) { BuildShaders(meta, m_shaders); }
|
// void BuildShaders(const hecl::HMDLMeta& meta) { BuildShaders(meta, m_shaders); }
|
||||||
};
|
};
|
||||||
|
|
||||||
class CBooModel {
|
class CBooModel {
|
||||||
|
@ -137,9 +136,9 @@ private:
|
||||||
CModel* m_model;
|
CModel* m_model;
|
||||||
std::vector<CBooSurface>* x0_surfaces;
|
std::vector<CBooSurface>* x0_surfaces;
|
||||||
const MaterialSet* x4_matSet;
|
const MaterialSet* x4_matSet;
|
||||||
const GeometryUniformLayout* m_geomLayout;
|
// const GeometryUniformLayout* m_geomLayout;
|
||||||
int m_matSetIdx = -1;
|
int m_matSetIdx = -1;
|
||||||
const std::unordered_map<int, CModelShaders::ShaderPipelines>* m_pipelines;
|
// const std::unordered_map<int, CModelShaders::ShaderPipelines>* m_pipelines;
|
||||||
std::unordered_map<CAssetId, TCachedToken<CTexture>> x1c_textures;
|
std::unordered_map<CAssetId, TCachedToken<CTexture>> x1c_textures;
|
||||||
zeus::CAABox x20_aabb;
|
zeus::CAABox x20_aabb;
|
||||||
CBooSurface* x38_firstUnsortedSurface = nullptr;
|
CBooSurface* x38_firstUnsortedSurface = nullptr;
|
||||||
|
@ -158,26 +157,26 @@ private:
|
||||||
CModelShaders::LightingUniform m_lightingData;
|
CModelShaders::LightingUniform m_lightingData;
|
||||||
|
|
||||||
/* metaforce addition: boo! */
|
/* metaforce addition: boo! */
|
||||||
size_t m_uniformDataSize = 0;
|
// size_t m_uniformDataSize = 0;
|
||||||
struct ModelInstance {
|
// struct ModelInstance {
|
||||||
boo::ObjToken<boo::IGraphicsBufferD> m_geomUniformBuffer;
|
// boo::ObjToken<boo::IGraphicsBufferD> m_geomUniformBuffer;
|
||||||
boo::ObjToken<boo::IGraphicsBufferD> m_uniformBuffer;
|
// boo::ObjToken<boo::IGraphicsBufferD> m_uniformBuffer;
|
||||||
std::vector<std::vector<boo::ObjToken<boo::IShaderDataBinding>>> m_shaderDataBindings;
|
// std::vector<std::vector<boo::ObjToken<boo::IShaderDataBinding>>> m_shaderDataBindings;
|
||||||
boo::ObjToken<boo::IGraphicsBufferD> m_dynamicVbo;
|
// boo::ObjToken<boo::IGraphicsBufferD> m_dynamicVbo;
|
||||||
|
//
|
||||||
|
// boo::ObjToken<boo::IGraphicsBuffer> GetBooVBO(const CBooModel& model, boo::IGraphicsDataFactory::Context& ctx);
|
||||||
|
// };
|
||||||
|
// std::vector<ModelInstance> m_instances;
|
||||||
|
// ModelInstance m_ballShadowInstance;
|
||||||
|
|
||||||
boo::ObjToken<boo::IGraphicsBuffer> GetBooVBO(const CBooModel& model, boo::IGraphicsDataFactory::Context& ctx);
|
// boo::ObjToken<boo::IGraphicsBufferS> m_staticVbo;
|
||||||
};
|
// boo::ObjToken<boo::IGraphicsBufferS> m_staticIbo;
|
||||||
std::vector<ModelInstance> m_instances;
|
//
|
||||||
ModelInstance m_ballShadowInstance;
|
// boo::ObjToken<boo::ITexture> m_lastDrawnShadowMap;
|
||||||
|
// boo::ObjToken<boo::ITexture> m_lastDrawnOneTexture;
|
||||||
|
// boo::ObjToken<boo::ITextureCubeR> m_lastDrawnReflectionCube;
|
||||||
|
|
||||||
boo::ObjToken<boo::IGraphicsBufferS> m_staticVbo;
|
// ModelInstance* PushNewModelInstance(int sharedLayoutBuf = -1, boo::IGraphicsDataFactory::Context* ctx = nullptr);
|
||||||
boo::ObjToken<boo::IGraphicsBufferS> m_staticIbo;
|
|
||||||
|
|
||||||
boo::ObjToken<boo::ITexture> m_lastDrawnShadowMap;
|
|
||||||
boo::ObjToken<boo::ITexture> m_lastDrawnOneTexture;
|
|
||||||
boo::ObjToken<boo::ITextureCubeR> m_lastDrawnReflectionCube;
|
|
||||||
|
|
||||||
ModelInstance* PushNewModelInstance(int sharedLayoutBuf = -1, boo::IGraphicsDataFactory::Context* ctx = nullptr);
|
|
||||||
void DrawAlphaSurfaces(const CModelFlags& flags) const;
|
void DrawAlphaSurfaces(const CModelFlags& flags) const;
|
||||||
void DrawNormalSurfaces(const CModelFlags& flags) const;
|
void DrawNormalSurfaces(const CModelFlags& flags) const;
|
||||||
void DrawSurfaces(const CModelFlags& flags) const;
|
void DrawSurfaces(const CModelFlags& flags) const;
|
||||||
|
@ -197,8 +196,9 @@ private:
|
||||||
public:
|
public:
|
||||||
~CBooModel();
|
~CBooModel();
|
||||||
CBooModel(TToken<CModel>& token, CModel* parent, std::vector<CBooSurface>* surfaces, SShader& shader,
|
CBooModel(TToken<CModel>& token, CModel* parent, std::vector<CBooSurface>* surfaces, SShader& shader,
|
||||||
const boo::ObjToken<boo::IGraphicsBufferS>& vbo, const boo::ObjToken<boo::IGraphicsBufferS>& ibo,
|
// TODO
|
||||||
const zeus::CAABox& aabb, u8 renderMask, int numInsts);
|
// boo::ObjToken<boo::IGraphicsBufferS> vbo, boo::ObjToken<boo::IGraphicsBufferS> ibo,
|
||||||
|
const zeus::CAABox& aabb, u8 renderMask);
|
||||||
|
|
||||||
static void MakeTexturesFromMats(const MaterialSet& matSet,
|
static void MakeTexturesFromMats(const MaterialSet& matSet,
|
||||||
std::unordered_map<CAssetId, TCachedToken<CTexture>>& toksOut, IObjectStore& store);
|
std::unordered_map<CAssetId, TCachedToken<CTexture>>& toksOut, IObjectStore& store);
|
||||||
|
@ -209,15 +209,13 @@ public:
|
||||||
void SetAmbientColor(const zeus::CColor& color) { m_lightingData.ambient = color; }
|
void SetAmbientColor(const zeus::CColor& color) { m_lightingData.ambient = color; }
|
||||||
void DisableAllLights();
|
void DisableAllLights();
|
||||||
void RemapMaterialData(SShader& shader);
|
void RemapMaterialData(SShader& shader);
|
||||||
void RemapMaterialData(SShader& shader, const std::unordered_map<int, CModelShaders::ShaderPipelines>& pipelines);
|
|
||||||
bool TryLockTextures();
|
bool TryLockTextures();
|
||||||
void UnlockTextures();
|
void UnlockTextures();
|
||||||
void SyncLoadTextures();
|
void SyncLoadTextures();
|
||||||
void Touch(int shaderIdx);
|
void Touch(int shaderIdx);
|
||||||
void VerifyCurrentShader(int shaderIdx);
|
void VerifyCurrentShader(int shaderIdx);
|
||||||
boo::ObjToken<boo::IGraphicsBufferD> UpdateUniformData(const CModelFlags& flags, const CSkinRules* cskr,
|
// boo::ObjToken<boo::IGraphicsBufferD> UpdateUniformData(const CModelFlags& flags, const CSkinRules* cskr,
|
||||||
const CPoseAsTransforms* pose, int sharedLayoutBuf = -1,
|
// const CPoseAsTransforms* pose, int sharedLayoutBuf = -1);
|
||||||
boo::IGraphicsDataFactory::Context* ctx = nullptr);
|
|
||||||
void DrawAlpha(const CModelFlags& flags, const CSkinRules* cskr, const CPoseAsTransforms* pose);
|
void DrawAlpha(const CModelFlags& flags, const CSkinRules* cskr, const CPoseAsTransforms* pose);
|
||||||
void DrawNormal(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);
|
void Draw(const CModelFlags& flags, const CSkinRules* cskr, const CPoseAsTransforms* pose);
|
||||||
|
@ -241,16 +239,16 @@ public:
|
||||||
static void EnsureViewDepStateCached(const CBooModel& model, const CBooSurface* surf, zeus::CMatrix4f* mtxsOut,
|
static void EnsureViewDepStateCached(const CBooModel& model, const CBooSurface* surf, zeus::CMatrix4f* mtxsOut,
|
||||||
float& alphaOut);
|
float& alphaOut);
|
||||||
|
|
||||||
static inline boo::ObjToken<boo::ITexture> g_shadowMap;
|
static inline std::shared_ptr<aurora::TextureHandle> g_shadowMap;
|
||||||
static inline zeus::CTransform g_shadowTexXf;
|
static inline zeus::CTransform g_shadowTexXf;
|
||||||
static void EnableShadowMaps(const boo::ObjToken<boo::ITexture>& map, const zeus::CTransform& texXf);
|
static void EnableShadowMaps(const std::shared_ptr<aurora::TextureHandle>& map, const zeus::CTransform& texXf);
|
||||||
static void DisableShadowMaps();
|
static void DisableShadowMaps();
|
||||||
|
|
||||||
static inline boo::ObjToken<boo::ITexture> g_disintegrateTexture;
|
static inline std::shared_ptr<aurora::TextureHandle> g_disintegrateTexture;
|
||||||
static void SetDisintegrateTexture(const boo::ObjToken<boo::ITexture>& map) { g_disintegrateTexture = map; }
|
static void SetDisintegrateTexture(const std::shared_ptr<aurora::TextureHandle>& map) { g_disintegrateTexture = map; }
|
||||||
|
|
||||||
static inline boo::ObjToken<boo::ITextureCubeR> g_reflectionCube;
|
static inline std::shared_ptr<aurora::TextureHandle> g_reflectionCube;
|
||||||
static void SetReflectionCube(const boo::ObjToken<boo::ITextureCubeR>& map) { g_reflectionCube = map; }
|
static void SetReflectionCube(const std::shared_ptr<aurora::TextureHandle>& map) { g_reflectionCube = map; }
|
||||||
|
|
||||||
static void SetDummyTextures(bool b) { g_DummyTextures = b; }
|
static void SetDummyTextures(bool b) { g_DummyTextures = b; }
|
||||||
static void SetRenderModelBlack(bool b) { g_RenderModelBlack = b; }
|
static void SetRenderModelBlack(bool b) { g_RenderModelBlack = b; }
|
||||||
|
@ -276,10 +274,10 @@ class CModel {
|
||||||
int x38_lastFrame;
|
int x38_lastFrame;
|
||||||
|
|
||||||
/* metaforce addition: boo! */
|
/* metaforce addition: boo! */
|
||||||
boo::ObjToken<boo::IGraphicsBufferS> m_staticVbo;
|
// boo::ObjToken<boo::IGraphicsBufferS> m_staticVbo;
|
||||||
hecl::HMDLMeta m_hmdlMeta;
|
hecl::HMDLMeta m_hmdlMeta;
|
||||||
std::unique_ptr<uint8_t[]> m_dynamicVertexData;
|
std::unique_ptr<uint8_t[]> m_dynamicVertexData;
|
||||||
boo::ObjToken<boo::IGraphicsBufferS> m_ibo;
|
// boo::ObjToken<boo::IGraphicsBufferS> m_ibo;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
using MaterialSet = DataSpec::DNAMP1::HMDLMaterialSet;
|
using MaterialSet = DataSpec::DNAMP1::HMDLMaterialSet;
|
||||||
|
@ -294,7 +292,7 @@ public:
|
||||||
const zeus::CAABox& GetAABB() const { return m_aabb; }
|
const zeus::CAABox& GetAABB() const { return m_aabb; }
|
||||||
CBooModel& GetInstance() { return *x28_modelInst; }
|
CBooModel& GetInstance() { return *x28_modelInst; }
|
||||||
const CBooModel& GetInstance() const { return *x28_modelInst; }
|
const CBooModel& GetInstance() const { return *x28_modelInst; }
|
||||||
std::unique_ptr<CBooModel> MakeNewInstance(int shaderIdx, int subInsts, bool lockParent = true);
|
std::unique_ptr<CBooModel> MakeNewInstance(int shaderIdx, bool lockParent = true);
|
||||||
void UpdateLastFrame() const { const_cast<CModel&>(*this).x38_lastFrame = CGraphics::GetFrameCounter(); }
|
void UpdateLastFrame() const { const_cast<CModel&>(*this).x38_lastFrame = CGraphics::GetFrameCounter(); }
|
||||||
u32 GetNumMaterialSets() const { return x18_matSets.size(); }
|
u32 GetNumMaterialSets() const { return x18_matSets.size(); }
|
||||||
|
|
||||||
|
@ -302,9 +300,9 @@ public:
|
||||||
zeus::CVector3f GetPoolVertex(size_t idx) const;
|
zeus::CVector3f GetPoolVertex(size_t idx) const;
|
||||||
size_t GetPoolNormalOffset(size_t idx) const;
|
size_t GetPoolNormalOffset(size_t idx) const;
|
||||||
zeus::CVector3f GetPoolNormal(size_t idx) const;
|
zeus::CVector3f GetPoolNormal(size_t idx) const;
|
||||||
void ApplyVerticesCPU(const boo::ObjToken<boo::IGraphicsBufferD>& vertBuf,
|
// void ApplyVerticesCPU(const boo::ObjToken<boo::IGraphicsBufferD>& vertBuf,
|
||||||
const std::vector<std::pair<zeus::CVector3f, zeus::CVector3f>>& vn) const;
|
// const std::vector<std::pair<zeus::CVector3f, zeus::CVector3f>>& vn) const;
|
||||||
void RestoreVerticesCPU(const boo::ObjToken<boo::IGraphicsBufferD>& vertBuf) const;
|
// void RestoreVerticesCPU(const boo::ObjToken<boo::IGraphicsBufferD>& vertBuf) const;
|
||||||
|
|
||||||
void _WarmupShaders();
|
void _WarmupShaders();
|
||||||
static void WarmupShaders(const SObjectTag& cmdlTag);
|
static void WarmupShaders(const SObjectTag& cmdlTag);
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -5,7 +5,7 @@
|
||||||
#include "Runtime/Graphics/CGraphics.hpp"
|
#include "Runtime/Graphics/CGraphics.hpp"
|
||||||
|
|
||||||
#include <amuse/DSPCodec.hpp>
|
#include <amuse/DSPCodec.hpp>
|
||||||
#include <hecl/Pipeline.hpp>
|
//#include <hecl/Pipeline.hpp>
|
||||||
#include <turbojpeg.h>
|
#include <turbojpeg.h>
|
||||||
|
|
||||||
namespace metaforce {
|
namespace metaforce {
|
||||||
|
@ -27,7 +27,7 @@ static const u16 StaticVolumeLookup[] = {
|
||||||
0x6CA2, 0x6E80, 0x7061, 0x7247, 0x7430, 0x761E, 0x7810, 0x7A06, 0x7C00, 0x7DFE, 0x8000};
|
0x6CA2, 0x6E80, 0x7061, 0x7247, 0x7430, 0x761E, 0x7810, 0x7A06, 0x7C00, 0x7DFE, 0x8000};
|
||||||
|
|
||||||
/* shared boo resources */
|
/* shared boo resources */
|
||||||
static boo::ObjToken<boo::IShaderPipeline> YUVShaderPipeline;
|
//static boo::ObjToken<boo::IShaderPipeline> YUVShaderPipeline;
|
||||||
static tjhandle TjHandle = nullptr;
|
static tjhandle TjHandle = nullptr;
|
||||||
|
|
||||||
/* RSF audio state */
|
/* RSF audio state */
|
||||||
|
@ -46,20 +46,20 @@ static float SfxVolume = 1.f;
|
||||||
static const char* BlockNames[] = {"SpecterViewBlock"};
|
static const char* BlockNames[] = {"SpecterViewBlock"};
|
||||||
static const char* TexNames[] = {"texY", "texU", "texV"};
|
static const char* TexNames[] = {"texY", "texU", "texV"};
|
||||||
|
|
||||||
void CMoviePlayer::Initialize(boo::IGraphicsDataFactory* factory) {
|
void CMoviePlayer::Initialize() {
|
||||||
switch (factory->platform()) {
|
// switch (factory->platform()) {
|
||||||
case boo::IGraphicsDataFactory::Platform::Vulkan:
|
// case boo::IGraphicsDataFactory::Platform::Vulkan:
|
||||||
g_PlatformMatrix.m[1][1] = -1.f;
|
// g_PlatformMatrix.m[1][1] = -1.f;
|
||||||
break;
|
// break;
|
||||||
default:
|
// default:
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
YUVShaderPipeline = hecl::conv->convert(Shader_CMoviePlayerShader{});
|
// YUVShaderPipeline = hecl::conv->convert(Shader_CMoviePlayerShader{});
|
||||||
TjHandle = tjInitDecompress();
|
TjHandle = tjInitDecompress();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMoviePlayer::Shutdown() {
|
void CMoviePlayer::Shutdown() {
|
||||||
YUVShaderPipeline.reset();
|
// YUVShaderPipeline.reset();
|
||||||
tjDestroy(TjHandle);
|
tjDestroy(TjHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,50 +202,50 @@ CMoviePlayer::CMoviePlayer(const char* path, float preLoadSeconds, bool loop, bo
|
||||||
xa0_bufferQueue.reserve(xf0_preLoadFrames);
|
xa0_bufferQueue.reserve(xf0_preLoadFrames);
|
||||||
|
|
||||||
/* All set for GPU resources */
|
/* All set for GPU resources */
|
||||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
// CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
||||||
m_blockBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(m_viewVertBlock), 1);
|
// m_blockBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(m_viewVertBlock), 1);
|
||||||
m_vertBuf = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(TexShaderVert), 4);
|
// m_vertBuf = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(TexShaderVert), 4);
|
||||||
|
//
|
||||||
/* Allocate textures here (rather than at decode time) */
|
// /* Allocate textures here (rather than at decode time) */
|
||||||
x80_textures.reserve(3);
|
// x80_textures.reserve(3);
|
||||||
for (int i = 0; i < 3; ++i) {
|
// for (int i = 0; i < 3; ++i) {
|
||||||
CTHPTextureSet& set = x80_textures.emplace_back();
|
// CTHPTextureSet& set = x80_textures.emplace_back();
|
||||||
if (deinterlace) {
|
// if (deinterlace) {
|
||||||
/* metaforce addition: this way interlaced THPs don't look horrible */
|
// /* metaforce addition: this way interlaced THPs don't look horrible */
|
||||||
set.Y[0] = ctx.newDynamicTexture(x6c_videoInfo.width, x6c_videoInfo.height / 2, boo::TextureFormat::I8,
|
// set.Y[0] = ctx.newDynamicTexture(x6c_videoInfo.width, x6c_videoInfo.height / 2, boo::TextureFormat::I8,
|
||||||
boo::TextureClampMode::Repeat);
|
// boo::TextureClampMode::Repeat);
|
||||||
set.Y[1] = ctx.newDynamicTexture(x6c_videoInfo.width, x6c_videoInfo.height / 2, boo::TextureFormat::I8,
|
// set.Y[1] = ctx.newDynamicTexture(x6c_videoInfo.width, x6c_videoInfo.height / 2, boo::TextureFormat::I8,
|
||||||
boo::TextureClampMode::Repeat);
|
// boo::TextureClampMode::Repeat);
|
||||||
set.U = ctx.newDynamicTexture(x6c_videoInfo.width / 2, x6c_videoInfo.height / 2, boo::TextureFormat::I8,
|
// set.U = ctx.newDynamicTexture(x6c_videoInfo.width / 2, x6c_videoInfo.height / 2, boo::TextureFormat::I8,
|
||||||
boo::TextureClampMode::Repeat);
|
// boo::TextureClampMode::Repeat);
|
||||||
set.V = ctx.newDynamicTexture(x6c_videoInfo.width / 2, x6c_videoInfo.height / 2, boo::TextureFormat::I8,
|
// set.V = ctx.newDynamicTexture(x6c_videoInfo.width / 2, x6c_videoInfo.height / 2, boo::TextureFormat::I8,
|
||||||
boo::TextureClampMode::Repeat);
|
// boo::TextureClampMode::Repeat);
|
||||||
|
//
|
||||||
boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {m_blockBuf.get()};
|
// boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {m_blockBuf.get()};
|
||||||
for (int j = 0; j < 2; ++j) {
|
// for (int j = 0; j < 2; ++j) {
|
||||||
boo::ObjToken<boo::ITexture> texs[] = {set.Y[j].get(), set.U.get(), set.V.get()};
|
// 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,
|
// set.binding[j] = ctx.newShaderDataBinding(YUVShaderPipeline, m_vertBuf.get(), nullptr, nullptr, 1, bufs,
|
||||||
nullptr, 3, texs, nullptr, nullptr);
|
// nullptr, 3, texs, nullptr, nullptr);
|
||||||
}
|
// }
|
||||||
} else {
|
// } else {
|
||||||
/* normal progressive presentation */
|
// /* normal progressive presentation */
|
||||||
set.Y[0] = ctx.newDynamicTexture(x6c_videoInfo.width, x6c_videoInfo.height, boo::TextureFormat::I8,
|
// set.Y[0] = ctx.newDynamicTexture(x6c_videoInfo.width, x6c_videoInfo.height, boo::TextureFormat::I8,
|
||||||
boo::TextureClampMode::Repeat);
|
// boo::TextureClampMode::Repeat);
|
||||||
set.U = ctx.newDynamicTexture(x6c_videoInfo.width / 2, x6c_videoInfo.height / 2, boo::TextureFormat::I8,
|
// set.U = ctx.newDynamicTexture(x6c_videoInfo.width / 2, x6c_videoInfo.height / 2, boo::TextureFormat::I8,
|
||||||
boo::TextureClampMode::Repeat);
|
// boo::TextureClampMode::Repeat);
|
||||||
set.V = ctx.newDynamicTexture(x6c_videoInfo.width / 2, x6c_videoInfo.height / 2, boo::TextureFormat::I8,
|
// set.V = ctx.newDynamicTexture(x6c_videoInfo.width / 2, x6c_videoInfo.height / 2, boo::TextureFormat::I8,
|
||||||
boo::TextureClampMode::Repeat);
|
// boo::TextureClampMode::Repeat);
|
||||||
|
//
|
||||||
boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {m_blockBuf.get()};
|
// boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {m_blockBuf.get()};
|
||||||
boo::ObjToken<boo::ITexture> texs[] = {set.Y[0].get(), set.U.get(), set.V.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,
|
// set.binding[0] = ctx.newShaderDataBinding(YUVShaderPipeline, m_vertBuf.get(), nullptr, nullptr, 1, bufs,
|
||||||
nullptr, 3, texs, nullptr, nullptr);
|
// nullptr, 3, texs, nullptr, nullptr);
|
||||||
}
|
// }
|
||||||
if (xf4_25_hasAudio)
|
// if (xf4_25_hasAudio)
|
||||||
set.audioBuf.reset(new s16[x28_thpHead.maxAudioSamples * 2]);
|
// set.audioBuf.reset(new s16[x28_thpHead.maxAudioSamples * 2]);
|
||||||
}
|
// }
|
||||||
return true;
|
// return true;
|
||||||
} BooTrace);
|
// } BooTrace);
|
||||||
|
|
||||||
/* Temporary planar YUV decode buffer, resulting planes copied to Boo */
|
/* 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)]);
|
m_yuvBuf.reset(new uint8_t[tjBufSizeYUV(x6c_videoInfo.width, x6c_videoInfo.height, TJ_420)]);
|
||||||
|
@ -260,7 +260,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});
|
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_viewVertBlock.finalAssign(m_viewVertBlock);
|
||||||
m_blockBuf->load(&m_viewVertBlock, sizeof(m_viewVertBlock));
|
// m_blockBuf->load(&m_viewVertBlock, sizeof(m_viewVertBlock));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMoviePlayer::SetStaticAudioVolume(int vol) {
|
void CMoviePlayer::SetStaticAudioVolume(int vol) {
|
||||||
|
@ -405,7 +405,7 @@ void CMoviePlayer::SetFrame(const zeus::CVector3f& a, const zeus::CVector3f& b,
|
||||||
m_frame[1].m_pos = b;
|
m_frame[1].m_pos = b;
|
||||||
m_frame[2].m_pos = d;
|
m_frame[2].m_pos = d;
|
||||||
m_frame[3].m_pos = c;
|
m_frame[3].m_pos = c;
|
||||||
m_vertBuf->load(m_frame, sizeof(m_frame));
|
// m_vertBuf->load(m_frame, sizeof(m_frame));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMoviePlayer::DrawFrame() {
|
void CMoviePlayer::DrawFrame() {
|
||||||
|
@ -415,8 +415,8 @@ void CMoviePlayer::DrawFrame() {
|
||||||
|
|
||||||
/* draw appropriate field */
|
/* draw appropriate field */
|
||||||
CTHPTextureSet& tex = x80_textures[xd0_drawTexSlot];
|
CTHPTextureSet& tex = x80_textures[xd0_drawTexSlot];
|
||||||
CGraphics::SetShaderDataBinding(tex.binding[m_deinterlace ? (xfc_fieldIndex != 0) : 0]);
|
// CGraphics::SetShaderDataBinding(tex.binding[m_deinterlace ? (xfc_fieldIndex != 0) : 0]);
|
||||||
CGraphics::DrawArray(0, 4);
|
// CGraphics::DrawArray(0, 4);
|
||||||
|
|
||||||
/* ensure second field is being displayed by VI to signal advance
|
/* ensure second field is being displayed by VI to signal advance
|
||||||
* (faked in metaforce with continuous xor) */
|
* (faked in metaforce with continuous xor) */
|
||||||
|
@ -532,27 +532,27 @@ void CMoviePlayer::DecodeFromRead(const void* data) {
|
||||||
|
|
||||||
if (m_deinterlace) {
|
if (m_deinterlace) {
|
||||||
/* Deinterlace into 2 discrete 60-fps half-res textures */
|
/* Deinterlace into 2 discrete 60-fps half-res textures */
|
||||||
u8* mappedData = (u8*)tex.Y[0]->map(planeSizeHalf);
|
// u8* mappedData = (u8*)tex.Y[0]->map(planeSizeHalf);
|
||||||
for (unsigned y = 0; y < x6c_videoInfo.height / 2; ++y) {
|
// for (unsigned y = 0; y < x6c_videoInfo.height / 2; ++y) {
|
||||||
memmove(mappedData + x6c_videoInfo.width * y, m_yuvBuf.get() + x6c_videoInfo.width * (y * 2),
|
// memmove(mappedData + x6c_videoInfo.width * y, m_yuvBuf.get() + x6c_videoInfo.width * (y * 2),
|
||||||
x6c_videoInfo.width);
|
// x6c_videoInfo.width);
|
||||||
}
|
// }
|
||||||
tex.Y[0]->unmap();
|
// tex.Y[0]->unmap();
|
||||||
|
//
|
||||||
mappedData = (u8*)tex.Y[1]->map(planeSizeHalf);
|
// mappedData = (u8*)tex.Y[1]->map(planeSizeHalf);
|
||||||
for (unsigned y = 0; y < x6c_videoInfo.height / 2; ++y) {
|
// 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),
|
// memmove(mappedData + x6c_videoInfo.width * y, m_yuvBuf.get() + x6c_videoInfo.width * (y * 2 + 1),
|
||||||
x6c_videoInfo.width);
|
// x6c_videoInfo.width);
|
||||||
}
|
// }
|
||||||
tex.Y[1]->unmap();
|
// tex.Y[1]->unmap();
|
||||||
|
//
|
||||||
tex.U->load(m_yuvBuf.get() + planeSize, planeSizeQuarter);
|
// tex.U->load(m_yuvBuf.get() + planeSize, planeSizeQuarter);
|
||||||
tex.V->load(m_yuvBuf.get() + planeSize + planeSizeQuarter, planeSizeQuarter);
|
// tex.V->load(m_yuvBuf.get() + planeSize + planeSizeQuarter, planeSizeQuarter);
|
||||||
} else {
|
} else {
|
||||||
/* Direct planar load */
|
/* Direct planar load */
|
||||||
tex.Y[0]->load(m_yuvBuf.get(), planeSize);
|
// tex.Y[0]->load(m_yuvBuf.get(), planeSize);
|
||||||
tex.U->load(m_yuvBuf.get() + planeSize, planeSizeQuarter);
|
// tex.U->load(m_yuvBuf.get() + planeSize, planeSizeQuarter);
|
||||||
tex.V->load(m_yuvBuf.get() + planeSize + planeSizeQuarter, planeSizeQuarter);
|
// tex.V->load(m_yuvBuf.get() + planeSize + planeSizeQuarter, planeSizeQuarter);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -5,9 +5,8 @@
|
||||||
|
|
||||||
#include "Runtime/CDvdFile.hpp"
|
#include "Runtime/CDvdFile.hpp"
|
||||||
#include "Runtime/RetroTypes.hpp"
|
#include "Runtime/RetroTypes.hpp"
|
||||||
|
#include "Runtime/Graphics/CGraphics.hpp"
|
||||||
|
|
||||||
#include <boo/IWindow.hpp>
|
|
||||||
#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
|
||||||
#include <zeus/CColor.hpp>
|
#include <zeus/CColor.hpp>
|
||||||
#include <zeus/CVector3f.hpp>
|
#include <zeus/CVector3f.hpp>
|
||||||
|
|
||||||
|
@ -72,13 +71,13 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CTHPTextureSet {
|
struct CTHPTextureSet {
|
||||||
boo::ObjToken<boo::ITextureD> Y[2];
|
std::shared_ptr<aurora::TextureHandle> Y[2];
|
||||||
boo::ObjToken<boo::ITextureD> U;
|
std::shared_ptr<aurora::TextureHandle> U;
|
||||||
boo::ObjToken<boo::ITextureD> V;
|
std::shared_ptr<aurora::TextureHandle> V;
|
||||||
u32 playedSamples = 0;
|
u32 playedSamples = 0;
|
||||||
u32 audioSamples = 0;
|
u32 audioSamples = 0;
|
||||||
std::unique_ptr<s16[]> audioBuf;
|
std::unique_ptr<s16[]> audioBuf;
|
||||||
boo::ObjToken<boo::IShaderDataBinding> binding[2];
|
// boo::ObjToken<boo::IShaderDataBinding> binding[2];
|
||||||
};
|
};
|
||||||
std::vector<CTHPTextureSet> x80_textures;
|
std::vector<CTHPTextureSet> x80_textures;
|
||||||
std::unique_ptr<uint8_t[]> x90_requestBuf;
|
std::unique_ptr<uint8_t[]> x90_requestBuf;
|
||||||
|
@ -118,11 +117,11 @@ private:
|
||||||
struct ViewBlock {
|
struct ViewBlock {
|
||||||
zeus::CMatrix4f m_mv;
|
zeus::CMatrix4f m_mv;
|
||||||
zeus::CColor m_color = zeus::skWhite;
|
zeus::CColor m_color = zeus::skWhite;
|
||||||
void setViewRect(const boo::SWindowRect& root, const boo::SWindowRect& sub) {
|
void setViewRect(const aurora::shaders::ClipRect& root, const aurora::shaders::ClipRect& sub) {
|
||||||
m_mv[0][0] = 2.0f / root.size[0];
|
m_mv[0][0] = 2.0f / root.width;
|
||||||
m_mv[1][1] = 2.0f / root.size[1];
|
m_mv[1][1] = 2.0f / root.height;
|
||||||
m_mv[3][0] = sub.location[0] * m_mv[0][0] - 1.0f;
|
m_mv[3][0] = sub.x * m_mv[0][0] - 1.0f;
|
||||||
m_mv[3][1] = sub.location[1] * m_mv[1][1] - 1.0f;
|
m_mv[3][1] = sub.y * m_mv[1][1] - 1.0f;
|
||||||
}
|
}
|
||||||
void finalAssign(const ViewBlock& other) {
|
void finalAssign(const ViewBlock& other) {
|
||||||
m_mv = g_PlatformMatrix * other.m_mv;
|
m_mv = g_PlatformMatrix * other.m_mv;
|
||||||
|
@ -131,8 +130,8 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
ViewBlock m_viewVertBlock;
|
ViewBlock m_viewVertBlock;
|
||||||
boo::ObjToken<boo::IGraphicsBufferD> m_blockBuf;
|
// boo::ObjToken<boo::IGraphicsBufferD> m_blockBuf;
|
||||||
boo::ObjToken<boo::IGraphicsBufferD> m_vertBuf;
|
// boo::ObjToken<boo::IGraphicsBufferD> m_vertBuf;
|
||||||
|
|
||||||
TexShaderVert m_frame[4];
|
TexShaderVert m_frame[4];
|
||||||
|
|
||||||
|
@ -167,7 +166,7 @@ public:
|
||||||
void Update(float dt);
|
void Update(float dt);
|
||||||
std::pair<u32, u32> GetVideoDimensions() const { return {x6c_videoInfo.width, x6c_videoInfo.height}; }
|
std::pair<u32, u32> GetVideoDimensions() const { return {x6c_videoInfo.width, x6c_videoInfo.height}; }
|
||||||
|
|
||||||
static void Initialize(boo::IGraphicsDataFactory* factory);
|
static void Initialize();
|
||||||
static void Shutdown();
|
static void Shutdown();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -13,11 +13,8 @@ CRainSplashGenerator::CRainSplashGenerator(const zeus::CVector3f& scale, u32 max
|
||||||
x30_alpha = std::min(1.f, alpha);
|
x30_alpha = std::min(1.f, alpha);
|
||||||
x44_genRate = std::min(maxSplashes, genRate);
|
x44_genRate = std::min(maxSplashes, genRate);
|
||||||
x0_rainSplashes.reserve(maxSplashes);
|
x0_rainSplashes.reserve(maxSplashes);
|
||||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
for (u32 i = 0; i < maxSplashes; ++i)
|
||||||
for (u32 i = 0; i < maxSplashes; ++i)
|
x0_rainSplashes.emplace_back();
|
||||||
x0_rainSplashes.emplace_back(ctx);
|
|
||||||
return true;
|
|
||||||
} BooTrace);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CRainSplashGenerator::SSplashLine::Draw(float alpha, float dt, const zeus::CVector3f& pos) {
|
void CRainSplashGenerator::SSplashLine::Draw(float alpha, float dt, const zeus::CVector3f& pos) {
|
||||||
|
@ -73,12 +70,12 @@ void CRainSplashGenerator::Draw(const zeus::CTransform& xf) {
|
||||||
DoDraw(xf);
|
DoDraw(xf);
|
||||||
}
|
}
|
||||||
|
|
||||||
CRainSplashGenerator::SSplashLine::SSplashLine(boo::IGraphicsDataFactory::Context& ctx)
|
CRainSplashGenerator::SSplashLine::SSplashLine()
|
||||||
: m_renderer(ctx, CLineRenderer::EPrimitiveMode::LineStrip, 3, nullptr, false) {}
|
: m_renderer(CLineRenderer::EPrimitiveMode::LineStrip, 3, nullptr, false) {}
|
||||||
|
|
||||||
CRainSplashGenerator::SRainSplash::SRainSplash(boo::IGraphicsDataFactory::Context& ctx) {
|
CRainSplashGenerator::SRainSplash::SRainSplash() {
|
||||||
for (size_t i = 0; i < x0_lines.capacity(); ++i) {
|
for (size_t i = 0; i < x0_lines.capacity(); ++i) {
|
||||||
x0_lines.emplace_back(ctx);
|
x0_lines.emplace_back();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ class CRainSplashGenerator {
|
||||||
u8 x15_length = 1;
|
u8 x15_length = 1;
|
||||||
bool x16_active = true; // used to be one-bit bitfield
|
bool x16_active = true; // used to be one-bit bitfield
|
||||||
CLineRenderer m_renderer;
|
CLineRenderer m_renderer;
|
||||||
explicit SSplashLine(boo::IGraphicsDataFactory::Context& ctx);
|
explicit SSplashLine();
|
||||||
void Update(float dt, CStateManager& mgr);
|
void Update(float dt, CStateManager& mgr);
|
||||||
void Draw(float alpha, float dt, const zeus::CVector3f& pos);
|
void Draw(float alpha, float dt, const zeus::CVector3f& pos);
|
||||||
void SetActive() { x16_active = true; }
|
void SetActive() { x16_active = true; }
|
||||||
|
@ -33,7 +33,7 @@ class CRainSplashGenerator {
|
||||||
rstl::reserved_vector<SSplashLine, 4> x0_lines;
|
rstl::reserved_vector<SSplashLine, 4> x0_lines;
|
||||||
zeus::CVector3f x64_pos;
|
zeus::CVector3f x64_pos;
|
||||||
float x70_ = 0.f;
|
float x70_ = 0.f;
|
||||||
explicit SRainSplash(boo::IGraphicsDataFactory::Context& ctx);
|
explicit SRainSplash();
|
||||||
SRainSplash(const SRainSplash&) = delete;
|
SRainSplash(const SRainSplash&) = delete;
|
||||||
SRainSplash& operator=(const SRainSplash&) = delete;
|
SRainSplash& operator=(const SRainSplash&) = delete;
|
||||||
SRainSplash(SRainSplash&&) = default;
|
SRainSplash(SRainSplash&&) = default;
|
||||||
|
|
|
@ -9,7 +9,7 @@ namespace metaforce {
|
||||||
static logvisor::Module Log("metaforce::CSkinnedModel");
|
static logvisor::Module Log("metaforce::CSkinnedModel");
|
||||||
|
|
||||||
CSkinnedModel::CSkinnedModel(TLockedToken<CModel> model, TLockedToken<CSkinRules> skinRules,
|
CSkinnedModel::CSkinnedModel(TLockedToken<CModel> model, TLockedToken<CSkinRules> skinRules,
|
||||||
TLockedToken<CCharLayoutInfo> layoutInfo, int shaderIdx, int drawInsts)
|
TLockedToken<CCharLayoutInfo> layoutInfo, int shaderIdx)
|
||||||
: x4_model(std::move(model)), x10_skinRules(std::move(skinRules)), x1c_layoutInfo(std::move(layoutInfo)) {
|
: x4_model(std::move(model)), x10_skinRules(std::move(skinRules)), x1c_layoutInfo(std::move(layoutInfo)) {
|
||||||
if (!x4_model) {
|
if (!x4_model) {
|
||||||
Log.report(logvisor::Fatal, FMT_STRING("bad model token provided to CSkinnedModel"));
|
Log.report(logvisor::Fatal, FMT_STRING("bad model token provided to CSkinnedModel"));
|
||||||
|
@ -20,35 +20,36 @@ CSkinnedModel::CSkinnedModel(TLockedToken<CModel> model, TLockedToken<CSkinRules
|
||||||
if (!x1c_layoutInfo) {
|
if (!x1c_layoutInfo) {
|
||||||
Log.report(logvisor::Fatal, FMT_STRING("bad character layout token provided to CSkinnedModel"));
|
Log.report(logvisor::Fatal, FMT_STRING("bad character layout token provided to CSkinnedModel"));
|
||||||
}
|
}
|
||||||
m_modelInst = x4_model->MakeNewInstance(shaderIdx, drawInsts);
|
m_modelInst = x4_model->MakeNewInstance(shaderIdx);
|
||||||
}
|
}
|
||||||
|
|
||||||
CSkinnedModel::CSkinnedModel(IObjectStore& store, CAssetId model, CAssetId skinRules, CAssetId layoutInfo,
|
CSkinnedModel::CSkinnedModel(IObjectStore& store, CAssetId model, CAssetId skinRules, CAssetId layoutInfo,
|
||||||
int shaderIdx, int drawInsts)
|
int shaderIdx)
|
||||||
: CSkinnedModel(store.GetObj(SObjectTag{FOURCC('CMDL'), model}), store.GetObj(SObjectTag{FOURCC('CSKR'), skinRules}),
|
: CSkinnedModel(store.GetObj(SObjectTag{FOURCC('CMDL'), model}), store.GetObj(SObjectTag{FOURCC('CSKR'), skinRules}),
|
||||||
store.GetObj(SObjectTag{FOURCC('CINF'), layoutInfo}), shaderIdx, drawInsts) {}
|
store.GetObj(SObjectTag{FOURCC('CINF'), layoutInfo}), shaderIdx) {}
|
||||||
|
|
||||||
void CSkinnedModel::Calculate(const CPoseAsTransforms& pose, const CModelFlags& drawFlags,
|
void CSkinnedModel::Calculate(const CPoseAsTransforms& pose, const CModelFlags& drawFlags,
|
||||||
const std::optional<CVertexMorphEffect>& morphEffect, const float* morphMagnitudes) {
|
const std::optional<CVertexMorphEffect>& morphEffect, const float* morphMagnitudes) {
|
||||||
if (morphEffect || g_PointGenFunc) {
|
// TODO
|
||||||
if (boo::ObjToken<boo::IGraphicsBufferD> vertBuf = m_modelInst->UpdateUniformData(drawFlags, nullptr, nullptr)) {
|
// if (morphEffect || g_PointGenFunc) {
|
||||||
x10_skinRules->TransformVerticesCPU(m_vertWorkspace, pose, *x4_model);
|
// if (boo::ObjToken<boo::IGraphicsBufferD> vertBuf = m_modelInst->UpdateUniformData(drawFlags, nullptr, nullptr)) {
|
||||||
if (morphEffect)
|
// x10_skinRules->TransformVerticesCPU(m_vertWorkspace, pose, *x4_model);
|
||||||
morphEffect->MorphVertices(m_vertWorkspace, morphMagnitudes, x10_skinRules, pose);
|
// if (morphEffect)
|
||||||
if (g_PointGenFunc)
|
// morphEffect->MorphVertices(m_vertWorkspace, morphMagnitudes, x10_skinRules, pose);
|
||||||
g_PointGenFunc(g_PointGenCtx, m_vertWorkspace);
|
// if (g_PointGenFunc)
|
||||||
x4_model->ApplyVerticesCPU(vertBuf, m_vertWorkspace);
|
// g_PointGenFunc(g_PointGenCtx, m_vertWorkspace);
|
||||||
m_modifiedVBO = true;
|
// x4_model->ApplyVerticesCPU(vertBuf, m_vertWorkspace);
|
||||||
}
|
// m_modifiedVBO = true;
|
||||||
} else {
|
// }
|
||||||
if (boo::ObjToken<boo::IGraphicsBufferD> vertBuf =
|
// } else {
|
||||||
m_modelInst->UpdateUniformData(drawFlags, x10_skinRules.GetObj(), &pose)) {
|
// if (boo::ObjToken<boo::IGraphicsBufferD> vertBuf =
|
||||||
if (m_modifiedVBO) {
|
// m_modelInst->UpdateUniformData(drawFlags, x10_skinRules.GetObj(), &pose)) {
|
||||||
x4_model->RestoreVerticesCPU(vertBuf);
|
// if (m_modifiedVBO) {
|
||||||
m_modifiedVBO = false;
|
// x4_model->RestoreVerticesCPU(vertBuf);
|
||||||
}
|
// m_modifiedVBO = false;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSkinnedModel::Draw(const CModelFlags& drawFlags) const {
|
void CSkinnedModel::Draw(const CModelFlags& drawFlags) const {
|
||||||
|
@ -58,8 +59,8 @@ void CSkinnedModel::Draw(const CModelFlags& drawFlags) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
CMorphableSkinnedModel::CMorphableSkinnedModel(IObjectStore& store, CAssetId model, CAssetId skinRules,
|
CMorphableSkinnedModel::CMorphableSkinnedModel(IObjectStore& store, CAssetId model, CAssetId skinRules,
|
||||||
CAssetId layoutInfo, int shaderIdx, int drawInsts)
|
CAssetId layoutInfo, int shaderIdx)
|
||||||
: CSkinnedModel(store, model, skinRules, layoutInfo, shaderIdx, drawInsts) {}
|
: CSkinnedModel(store, model, skinRules, layoutInfo, shaderIdx) {}
|
||||||
|
|
||||||
CSkinnedModel::FPointGenerator CSkinnedModel::g_PointGenFunc = nullptr;
|
CSkinnedModel::FPointGenerator CSkinnedModel::g_PointGenFunc = nullptr;
|
||||||
void* CSkinnedModel::g_PointGenCtx = nullptr;
|
void* CSkinnedModel::g_PointGenCtx = nullptr;
|
||||||
|
|
|
@ -30,11 +30,10 @@ class CSkinnedModel {
|
||||||
public:
|
public:
|
||||||
enum class EDataOwnership { Zero, One };
|
enum class EDataOwnership { Zero, One };
|
||||||
CSkinnedModel(TLockedToken<CModel> model, TLockedToken<CSkinRules> skinRules,
|
CSkinnedModel(TLockedToken<CModel> model, TLockedToken<CSkinRules> skinRules,
|
||||||
TLockedToken<CCharLayoutInfo> layoutInfo, int shaderIdx, int drawInsts);
|
TLockedToken<CCharLayoutInfo> layoutInfo, int shaderIdx);
|
||||||
CSkinnedModel(IObjectStore& store, CAssetId model, CAssetId skinRules, CAssetId layoutInfo, int shaderIdx,
|
CSkinnedModel(IObjectStore& store, CAssetId model, CAssetId skinRules, CAssetId layoutInfo, int shaderIdx);
|
||||||
int drawInsts);
|
std::unique_ptr<CSkinnedModel> Clone(int shaderIdx = 0) const {
|
||||||
std::unique_ptr<CSkinnedModel> Clone(int shaderIdx = 0, int drawInsts = 1) const {
|
return std::make_unique<CSkinnedModel>(x4_model, x10_skinRules, x1c_layoutInfo, shaderIdx);
|
||||||
return std::make_unique<CSkinnedModel>(x4_model, x10_skinRules, x1c_layoutInfo, shaderIdx, drawInsts);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const TLockedToken<CModel>& GetModel() const { return x4_model; }
|
const TLockedToken<CModel>& GetModel() const { return x4_model; }
|
||||||
|
@ -61,8 +60,7 @@ class CMorphableSkinnedModel : public CSkinnedModel {
|
||||||
std::unique_ptr<float[]> x40_morphMagnitudes;
|
std::unique_ptr<float[]> x40_morphMagnitudes;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CMorphableSkinnedModel(IObjectStore& store, CAssetId model, CAssetId skinRules, CAssetId layoutInfo, int shaderIdx,
|
CMorphableSkinnedModel(IObjectStore& store, CAssetId model, CAssetId skinRules, CAssetId layoutInfo, int shaderIdx);
|
||||||
int drawInsts);
|
|
||||||
const float* GetMorphMagnitudes() const { return x40_morphMagnitudes.get(); }
|
const float* GetMorphMagnitudes() const { return x40_morphMagnitudes.get(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
#include "Runtime/IOStreams.hpp"
|
#include "Runtime/IOStreams.hpp"
|
||||||
#include "Runtime/Graphics/CGraphics.hpp"
|
#include "Runtime/Graphics/CGraphics.hpp"
|
||||||
|
|
||||||
#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
//#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
||||||
|
|
||||||
namespace metaforce {
|
namespace metaforce {
|
||||||
class CVParamTransfer;
|
class CVParamTransfer;
|
||||||
|
@ -32,34 +32,35 @@ private:
|
||||||
u16 x4_w;
|
u16 x4_w;
|
||||||
u16 x6_h;
|
u16 x6_h;
|
||||||
u32 x8_mips;
|
u32 x8_mips;
|
||||||
boo::ObjToken<boo::ITexture> m_booTex;
|
// boo::ObjToken<boo::ITexture> m_booTex;
|
||||||
boo::ObjToken<boo::ITexture> m_paletteTex;
|
std::shared_ptr<aurora::TextureHandle> m_tex;
|
||||||
|
std::shared_ptr<aurora::TextureHandle> m_paletteTex;
|
||||||
std::unique_ptr<u8[]> m_otex;
|
std::unique_ptr<u8[]> m_otex;
|
||||||
EFontType m_ftype = EFontType::None;
|
EFontType m_ftype = EFontType::None;
|
||||||
const CTextureInfo* m_textureInfo;
|
const CTextureInfo* m_textureInfo;
|
||||||
|
|
||||||
size_t ComputeMippedTexelCount() const;
|
size_t ComputeMippedTexelCount() const;
|
||||||
size_t ComputeMippedBlockCountDXT1() const;
|
size_t ComputeMippedBlockCountDXT1() const;
|
||||||
void BuildI4FromGCN(CInputStream& in);
|
void BuildI4FromGCN(CInputStream& in, std::string_view label);
|
||||||
void BuildI8FromGCN(CInputStream& in);
|
void BuildI8FromGCN(CInputStream& in, std::string_view label);
|
||||||
void BuildIA4FromGCN(CInputStream& in);
|
void BuildIA4FromGCN(CInputStream& in, std::string_view label);
|
||||||
void BuildIA8FromGCN(CInputStream& in);
|
void BuildIA8FromGCN(CInputStream& in, std::string_view label);
|
||||||
void BuildC4FromGCN(CInputStream& in);
|
void BuildC4FromGCN(CInputStream& in, std::string_view label);
|
||||||
void BuildC8FromGCN(CInputStream& in);
|
void BuildC8FromGCN(CInputStream& in, std::string_view label);
|
||||||
void BuildC14X2FromGCN(CInputStream& in);
|
void BuildC14X2FromGCN(CInputStream& in, std::string_view label);
|
||||||
void BuildRGB565FromGCN(CInputStream& in);
|
void BuildRGB565FromGCN(CInputStream& in, std::string_view label);
|
||||||
void BuildRGB5A3FromGCN(CInputStream& in);
|
void BuildRGB5A3FromGCN(CInputStream& in, std::string_view label);
|
||||||
void BuildRGBA8FromGCN(CInputStream& in);
|
void BuildRGBA8FromGCN(CInputStream& in, std::string_view label);
|
||||||
void BuildDXT1FromGCN(CInputStream& in);
|
void BuildDXT1FromGCN(CInputStream& in, std::string_view label);
|
||||||
void BuildRGBA8(const void* data, size_t length);
|
void BuildRGBA8(const void* data, size_t length, std::string_view label);
|
||||||
void BuildC8(const void* data, size_t length);
|
void BuildC8(const void* data, size_t length, std::string_view label);
|
||||||
void BuildC8Font(const void* data, EFontType ftype);
|
void BuildC8Font(const void* data, EFontType ftype, std::string_view label);
|
||||||
void BuildDXT1(const void* data, size_t length);
|
void BuildDXT1(const void* data, size_t length, std::string_view label);
|
||||||
void BuildDXT3(const void* data, size_t length);
|
void BuildDXT3(const void* data, size_t length, std::string_view label);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CTexture(ETexelFormat, s16, s16, s32);
|
CTexture(ETexelFormat, s16, s16, s32);
|
||||||
CTexture(std::unique_ptr<u8[]>&& in, u32 length, bool otex, const CTextureInfo* inf);
|
CTexture(std::unique_ptr<u8[]>&& in, u32 length, bool otex, const CTextureInfo* inf, CAssetId id);
|
||||||
enum class EClampMode { None, One };
|
enum class EClampMode { None, One };
|
||||||
ETexelFormat GetTexelFormat() const { return x0_fmt; }
|
ETexelFormat GetTexelFormat() const { return x0_fmt; }
|
||||||
ETexelFormat GetMemoryCardTexelFormat() const {
|
ETexelFormat GetMemoryCardTexelFormat() const {
|
||||||
|
@ -69,10 +70,11 @@ public:
|
||||||
u16 GetHeight() const { return x6_h; }
|
u16 GetHeight() const { return x6_h; }
|
||||||
u32 GetNumMips() const { return x8_mips; }
|
u32 GetNumMips() const { return x8_mips; }
|
||||||
void Load(int slot, EClampMode clamp) const;
|
void Load(int slot, EClampMode clamp) const;
|
||||||
const boo::ObjToken<boo::ITexture>& GetBooTexture() const { return m_booTex; }
|
const std::shared_ptr<aurora::TextureHandle>& GetTexture() const { return m_tex; }
|
||||||
const boo::ObjToken<boo::ITexture>& GetPaletteTexture() const { return m_paletteTex; }
|
// const boo::ObjToken<boo::ITexture>& GetBooTexture() const { return m_booTex; }
|
||||||
|
const std::shared_ptr<aurora::TextureHandle>& GetPaletteTexture() const { return m_paletteTex; }
|
||||||
std::unique_ptr<u8[]> BuildMemoryCardTex(u32& sizeOut, ETexelFormat& fmtOut, std::unique_ptr<u8[]>& paletteOut) const;
|
std::unique_ptr<u8[]> BuildMemoryCardTex(u32& sizeOut, ETexelFormat& fmtOut, std::unique_ptr<u8[]>& paletteOut) const;
|
||||||
const boo::ObjToken<boo::ITexture>& GetFontTexture(EFontType tp);
|
const std::shared_ptr<aurora::TextureHandle>& GetFontTexture(EFontType tp);
|
||||||
|
|
||||||
const CTextureInfo* GetTextureInfo() const { return m_textureInfo; }
|
const CTextureInfo* GetTextureInfo() const { return m_textureInfo; }
|
||||||
};
|
};
|
||||||
|
|
|
@ -75,7 +75,7 @@ size_t CTexture::ComputeMippedBlockCountDXT1() const {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTexture::BuildI4FromGCN(CInputStream& in) {
|
void CTexture::BuildI4FromGCN(CInputStream& in, std::string_view label) {
|
||||||
const size_t texelCount = ComputeMippedTexelCount();
|
const size_t texelCount = ComputeMippedTexelCount();
|
||||||
std::unique_ptr<RGBA8[]> buf(new RGBA8[texelCount]);
|
std::unique_ptr<RGBA8[]> buf(new RGBA8[texelCount]);
|
||||||
|
|
||||||
|
@ -89,11 +89,11 @@ void CTexture::BuildI4FromGCN(CInputStream& in) {
|
||||||
const int baseY = by * 8;
|
const int baseY = by * 8;
|
||||||
for (int bx = 0; bx < bwidth; ++bx) {
|
for (int bx = 0; bx < bwidth; ++bx) {
|
||||||
const int baseX = bx * 8;
|
const int baseX = bx * 8;
|
||||||
for (int y = 0; y < 8; ++y) {
|
for (int y = 0; y < std::min(h, 8); ++y) {
|
||||||
RGBA8* target = targetMip + (baseY + y) * w + baseX;
|
RGBA8* target = targetMip + (baseY + y) * w + baseX;
|
||||||
std::array<u8, 4> source;
|
std::array<u8, 4> source;
|
||||||
in.readBytesToBuf(source.data(), source.size());
|
in.readBytesToBuf(source.data(), std::min(size_t(w) / 4, source.size()));
|
||||||
for (size_t x = 0; x < 8; ++x) {
|
for (size_t x = 0; x < std::min(w, 8); ++x) {
|
||||||
target[x].r = Convert4To8(source[x / 2] >> ((x & 1) ? 0 : 4) & 0xf);
|
target[x].r = Convert4To8(source[x / 2] >> ((x & 1) ? 0 : 4) & 0xf);
|
||||||
target[x].g = target[x].r;
|
target[x].g = target[x].r;
|
||||||
target[x].b = target[x].r;
|
target[x].b = target[x].r;
|
||||||
|
@ -111,15 +111,11 @@ void CTexture::BuildI4FromGCN(CInputStream& in) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
m_tex = aurora::new_static_texture_2d(x4_w, x6_h, x8_mips, aurora::shaders::TextureFormat::RGBA8,
|
||||||
m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::RGBA8, boo::TextureClampMode::Repeat,
|
{reinterpret_cast<const uint8_t*>(buf.get()), texelCount * 4}, label);
|
||||||
buf.get(), texelCount * 4)
|
|
||||||
.get();
|
|
||||||
return true;
|
|
||||||
} BooTrace);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTexture::BuildI8FromGCN(CInputStream& in) {
|
void CTexture::BuildI8FromGCN(CInputStream& in, std::string_view label) {
|
||||||
const size_t texelCount = ComputeMippedTexelCount();
|
const size_t texelCount = ComputeMippedTexelCount();
|
||||||
std::unique_ptr<RGBA8[]> buf(new RGBA8[texelCount]);
|
std::unique_ptr<RGBA8[]> buf(new RGBA8[texelCount]);
|
||||||
|
|
||||||
|
@ -155,15 +151,11 @@ void CTexture::BuildI8FromGCN(CInputStream& in) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
m_tex = aurora::new_static_texture_2d(x4_w, x6_h, x8_mips, aurora::shaders::TextureFormat::RGBA8,
|
||||||
m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::RGBA8, boo::TextureClampMode::Repeat,
|
{reinterpret_cast<const uint8_t*>(buf.get()), texelCount * 4}, label);
|
||||||
buf.get(), texelCount * 4)
|
|
||||||
.get();
|
|
||||||
return true;
|
|
||||||
} BooTrace);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTexture::BuildIA4FromGCN(CInputStream& in) {
|
void CTexture::BuildIA4FromGCN(CInputStream& in, std::string_view label) {
|
||||||
const size_t texelCount = ComputeMippedTexelCount();
|
const size_t texelCount = ComputeMippedTexelCount();
|
||||||
std::unique_ptr<RGBA8[]> buf(new RGBA8[texelCount]);
|
std::unique_ptr<RGBA8[]> buf(new RGBA8[texelCount]);
|
||||||
|
|
||||||
|
@ -200,15 +192,11 @@ void CTexture::BuildIA4FromGCN(CInputStream& in) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
m_tex = aurora::new_static_texture_2d(x4_w, x6_h, x8_mips, aurora::shaders::TextureFormat::RGBA8,
|
||||||
m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::RGBA8, boo::TextureClampMode::Repeat,
|
{reinterpret_cast<const uint8_t*>(buf.get()), texelCount * 4}, label);
|
||||||
buf.get(), texelCount * 4)
|
|
||||||
.get();
|
|
||||||
return true;
|
|
||||||
} BooTrace);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTexture::BuildIA8FromGCN(CInputStream& in) {
|
void CTexture::BuildIA8FromGCN(CInputStream& in, std::string_view label) {
|
||||||
const size_t texelCount = ComputeMippedTexelCount();
|
const size_t texelCount = ComputeMippedTexelCount();
|
||||||
std::unique_ptr<RGBA8[]> buf(new RGBA8[texelCount]);
|
std::unique_ptr<RGBA8[]> buf(new RGBA8[texelCount]);
|
||||||
|
|
||||||
|
@ -245,12 +233,8 @@ void CTexture::BuildIA8FromGCN(CInputStream& in) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
m_tex = aurora::new_static_texture_2d(x4_w, x6_h, x8_mips, aurora::shaders::TextureFormat::RGBA8,
|
||||||
m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::RGBA8, boo::TextureClampMode::Repeat,
|
{reinterpret_cast<const uint8_t*>(buf.get()), texelCount * 4}, label);
|
||||||
buf.get(), texelCount * 4)
|
|
||||||
.get();
|
|
||||||
return true;
|
|
||||||
} BooTrace);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::vector<RGBA8> DecodePalette(int numEntries, CInputStream& in) {
|
static std::vector<RGBA8> DecodePalette(int numEntries, CInputStream& in) {
|
||||||
|
@ -294,7 +278,7 @@ static std::vector<RGBA8> DecodePalette(int numEntries, CInputStream& in) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTexture::BuildC4FromGCN(CInputStream& in) {
|
void CTexture::BuildC4FromGCN(CInputStream& in, std::string_view label) {
|
||||||
const size_t texelCount = ComputeMippedTexelCount();
|
const size_t texelCount = ComputeMippedTexelCount();
|
||||||
std::unique_ptr<RGBA8[]> buf(new RGBA8[texelCount]);
|
std::unique_ptr<RGBA8[]> buf(new RGBA8[texelCount]);
|
||||||
std::vector<RGBA8> palette = DecodePalette(16, in);
|
std::vector<RGBA8> palette = DecodePalette(16, in);
|
||||||
|
@ -328,15 +312,11 @@ void CTexture::BuildC4FromGCN(CInputStream& in) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
m_tex = aurora::new_static_texture_2d(x4_w, x6_h, x8_mips, aurora::shaders::TextureFormat::RGBA8,
|
||||||
m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::RGBA8, boo::TextureClampMode::Repeat,
|
{reinterpret_cast<const uint8_t*>(buf.get()), texelCount * 4}, label);
|
||||||
buf.get(), texelCount * 4)
|
|
||||||
.get();
|
|
||||||
return true;
|
|
||||||
} BooTrace);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTexture::BuildC8FromGCN(CInputStream& in) {
|
void CTexture::BuildC8FromGCN(CInputStream& in, std::string_view label) {
|
||||||
const size_t texelCount = ComputeMippedTexelCount();
|
const size_t texelCount = ComputeMippedTexelCount();
|
||||||
std::unique_ptr<RGBA8[]> buf(new RGBA8[texelCount]);
|
std::unique_ptr<RGBA8[]> buf(new RGBA8[texelCount]);
|
||||||
std::vector<RGBA8> palette = DecodePalette(256, in);
|
std::vector<RGBA8> palette = DecodePalette(256, in);
|
||||||
|
@ -370,17 +350,15 @@ void CTexture::BuildC8FromGCN(CInputStream& in) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
m_tex = aurora::new_static_texture_2d(x4_w, x6_h, x8_mips, aurora::shaders::TextureFormat::RGBA8,
|
||||||
m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::RGBA8, boo::TextureClampMode::Repeat,
|
{reinterpret_cast<const uint8_t*>(buf.get()), texelCount * 4}, label);
|
||||||
buf.get(), texelCount * 4)
|
|
||||||
.get();
|
|
||||||
return true;
|
|
||||||
} BooTrace);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTexture::BuildC14X2FromGCN(CInputStream& in) {}
|
void CTexture::BuildC14X2FromGCN(CInputStream& in, std::string_view label) {
|
||||||
|
Log.report(logvisor::Fatal, FMT_STRING("C14X2 not implemented"));
|
||||||
|
}
|
||||||
|
|
||||||
void CTexture::BuildRGB565FromGCN(CInputStream& in) {
|
void CTexture::BuildRGB565FromGCN(CInputStream& in, std::string_view label) {
|
||||||
const size_t texelCount = ComputeMippedTexelCount();
|
const size_t texelCount = ComputeMippedTexelCount();
|
||||||
std::unique_ptr<RGBA8[]> buf(new RGBA8[texelCount]);
|
std::unique_ptr<RGBA8[]> buf(new RGBA8[texelCount]);
|
||||||
|
|
||||||
|
@ -415,15 +393,11 @@ void CTexture::BuildRGB565FromGCN(CInputStream& in) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
m_tex = aurora::new_static_texture_2d(x4_w, x6_h, x8_mips, aurora::shaders::TextureFormat::RGBA8,
|
||||||
m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::RGBA8, boo::TextureClampMode::Repeat,
|
{reinterpret_cast<const uint8_t*>(buf.get()), texelCount * 4}, label);
|
||||||
buf.get(), texelCount * 4)
|
|
||||||
.get();
|
|
||||||
return true;
|
|
||||||
} BooTrace);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTexture::BuildRGB5A3FromGCN(CInputStream& in) {
|
void CTexture::BuildRGB5A3FromGCN(CInputStream& in, std::string_view label) {
|
||||||
size_t texelCount = ComputeMippedTexelCount();
|
size_t texelCount = ComputeMippedTexelCount();
|
||||||
std::unique_ptr<RGBA8[]> buf(new RGBA8[texelCount]);
|
std::unique_ptr<RGBA8[]> buf(new RGBA8[texelCount]);
|
||||||
|
|
||||||
|
@ -465,15 +439,11 @@ void CTexture::BuildRGB5A3FromGCN(CInputStream& in) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
m_tex = aurora::new_static_texture_2d(x4_w, x6_h, x8_mips, aurora::shaders::TextureFormat::RGBA8,
|
||||||
m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::RGBA8, boo::TextureClampMode::Repeat,
|
{reinterpret_cast<const uint8_t*>(buf.get()), texelCount * 4}, label);
|
||||||
buf.get(), texelCount * 4)
|
|
||||||
.get();
|
|
||||||
return true;
|
|
||||||
} BooTrace);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTexture::BuildRGBA8FromGCN(CInputStream& in) {
|
void CTexture::BuildRGBA8FromGCN(CInputStream& in, std::string_view label) {
|
||||||
const size_t texelCount = ComputeMippedTexelCount();
|
const size_t texelCount = ComputeMippedTexelCount();
|
||||||
std::unique_ptr<RGBA8[]> buf(new RGBA8[texelCount]);
|
std::unique_ptr<RGBA8[]> buf(new RGBA8[texelCount]);
|
||||||
|
|
||||||
|
@ -514,15 +484,11 @@ void CTexture::BuildRGBA8FromGCN(CInputStream& in) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
m_tex = aurora::new_static_texture_2d(x4_w, x6_h, x8_mips, aurora::shaders::TextureFormat::RGBA8,
|
||||||
m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::RGBA8, boo::TextureClampMode::Repeat,
|
{reinterpret_cast<const uint8_t*>(buf.get()), texelCount * 4}, label);
|
||||||
buf.get(), texelCount * 4)
|
|
||||||
.get();
|
|
||||||
return true;
|
|
||||||
} BooTrace);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTexture::BuildDXT1FromGCN(CInputStream& in) {
|
void CTexture::BuildDXT1FromGCN(CInputStream& in, std::string_view label) {
|
||||||
const size_t blockCount = ComputeMippedBlockCountDXT1();
|
const size_t blockCount = ComputeMippedBlockCountDXT1();
|
||||||
std::unique_ptr<DXT1Block[]> buf(new DXT1Block[blockCount]);
|
std::unique_ptr<DXT1Block[]> buf(new DXT1Block[blockCount]);
|
||||||
|
|
||||||
|
@ -566,48 +532,35 @@ void CTexture::BuildDXT1FromGCN(CInputStream& in) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
m_tex = aurora::new_static_texture_2d(x4_w, x6_h, x8_mips, aurora::shaders::TextureFormat::DXT1,
|
||||||
m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::DXT1, boo::TextureClampMode::Repeat,
|
{reinterpret_cast<const uint8_t*>(buf.get()), blockCount * 8}, label);
|
||||||
buf.get(), blockCount * 8)
|
|
||||||
.get();
|
|
||||||
return true;
|
|
||||||
} BooTrace);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTexture::BuildRGBA8(const void* data, size_t length) {
|
void CTexture::BuildRGBA8(const void* data, size_t length, std::string_view label) {
|
||||||
size_t texelCount = ComputeMippedTexelCount();
|
size_t texelCount = ComputeMippedTexelCount();
|
||||||
size_t expectedSize = texelCount * 4;
|
size_t expectedSize = texelCount * 4;
|
||||||
if (expectedSize > length)
|
if (expectedSize > length)
|
||||||
Log.report(logvisor::Fatal, FMT_STRING("insufficient TXTR length ({}/{})"), length, expectedSize);
|
Log.report(logvisor::Fatal, FMT_STRING("insufficient TXTR length ({}/{})"), length, expectedSize);
|
||||||
|
|
||||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
m_tex = aurora::new_static_texture_2d(x4_w, x6_h, x8_mips, aurora::shaders::TextureFormat::RGBA8,
|
||||||
m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::RGBA8, boo::TextureClampMode::Repeat, data,
|
{reinterpret_cast<const uint8_t*>(data), expectedSize}, label);
|
||||||
expectedSize)
|
|
||||||
.get();
|
|
||||||
return true;
|
|
||||||
} BooTrace);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTexture::BuildC8(const void* data, size_t length) {
|
void CTexture::BuildC8(const void* data, size_t length, std::string_view label) {
|
||||||
size_t texelCount = ComputeMippedTexelCount();
|
size_t texelCount = ComputeMippedTexelCount();
|
||||||
if (texelCount > length)
|
if (texelCount > length)
|
||||||
Log.report(logvisor::Fatal, FMT_STRING("insufficient TXTR length ({}/{})"), length, texelCount);
|
Log.report(logvisor::Fatal, FMT_STRING("insufficient TXTR length ({}/{})"), length, texelCount);
|
||||||
|
|
||||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
uint32_t nentries = hecl::SBig(*reinterpret_cast<const uint32_t*>(data));
|
||||||
uint32_t nentries = hecl::SBig(*reinterpret_cast<const uint32_t*>(data));
|
const u8* paletteTexels = reinterpret_cast<const u8*>(data) + 4;
|
||||||
const u8* paletteTexels = reinterpret_cast<const u8*>(data) + 4;
|
const u8* texels = reinterpret_cast<const u8*>(data) + 4 + nentries * 4;
|
||||||
const u8* texels = reinterpret_cast<const u8*>(data) + 4 + nentries * 4;
|
m_paletteTex = aurora::new_static_texture_2d(nentries, 1, 1, aurora::shaders::TextureFormat::RGBA8,
|
||||||
m_paletteTex = ctx.newStaticTexture(nentries, 1, 1, boo::TextureFormat::RGBA8, boo::TextureClampMode::Repeat,
|
{paletteTexels, nentries * 4}, label);
|
||||||
paletteTexels, nentries * 4)
|
m_tex = aurora::new_static_texture_2d(x4_w, x6_h, x8_mips, aurora::shaders::TextureFormat::R8, {texels, texelCount},
|
||||||
.get();
|
label);
|
||||||
m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::I8, boo::TextureClampMode::Repeat, texels,
|
|
||||||
texelCount)
|
|
||||||
.get();
|
|
||||||
return true;
|
|
||||||
} BooTrace);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTexture::BuildC8Font(const void* data, EFontType ftype) {
|
void CTexture::BuildC8Font(const void* data, EFontType ftype, std::string_view label) {
|
||||||
size_t texelCount = ComputeMippedTexelCount();
|
size_t texelCount = ComputeMippedTexelCount();
|
||||||
|
|
||||||
size_t layerCount = 1;
|
size_t layerCount = 1;
|
||||||
|
@ -697,30 +650,58 @@ void CTexture::BuildC8Font(const void* data, EFontType ftype) {
|
||||||
h /= 2;
|
h /= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
// TODO array tex
|
||||||
m_booTex = ctx.newStaticArrayTexture(x4_w, x6_h, layerCount, x8_mips, boo::TextureFormat::RGBA8,
|
// CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
||||||
boo::TextureClampMode::Repeat, buf.get(), texelCount * layerCount * 4)
|
// m_booTex = ctx.newStaticArrayTexture(x4_w, x6_h, layerCount, x8_mips, boo::TextureFormat::RGBA8,
|
||||||
.get();
|
// boo::TextureClampMode::Repeat, buf.get(), texelCount * layerCount * 4)
|
||||||
return true;
|
// .get();
|
||||||
} BooTrace);
|
// return true;
|
||||||
|
// } BooTrace);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTexture::BuildDXT1(const void* data, size_t length) {
|
void CTexture::BuildDXT1(const void* data, size_t length, std::string_view label) {
|
||||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
m_tex = aurora::new_static_texture_2d(x4_w, x6_h, x8_mips, aurora::shaders::TextureFormat::DXT1,
|
||||||
m_booTex =
|
{reinterpret_cast<const uint8_t*>(data), length}, label);
|
||||||
ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::DXT1, boo::TextureClampMode::Repeat, data, length)
|
|
||||||
.get();
|
|
||||||
return true;
|
|
||||||
} BooTrace);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTexture::BuildDXT3(const void* data, size_t length) {
|
void CTexture::BuildDXT3(const void* data, size_t length, std::string_view label) {
|
||||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
m_tex = aurora::new_static_texture_2d(x4_w, x6_h, x8_mips, aurora::shaders::TextureFormat::DXT3,
|
||||||
m_booTex =
|
{reinterpret_cast<const uint8_t*>(data), length}, label);
|
||||||
ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::DXT3, boo::TextureClampMode::Repeat, data, length)
|
}
|
||||||
.get();
|
|
||||||
return true;
|
static std::string_view TextureFormatString(ETexelFormat format) {
|
||||||
} BooTrace);
|
switch (format) {
|
||||||
|
case ETexelFormat::I4:
|
||||||
|
return "I4"sv;
|
||||||
|
case ETexelFormat::I8:
|
||||||
|
return "I8"sv;
|
||||||
|
case ETexelFormat::IA4:
|
||||||
|
return "IA4"sv;
|
||||||
|
case ETexelFormat::IA8:
|
||||||
|
return "IA8"sv;
|
||||||
|
case ETexelFormat::C4:
|
||||||
|
return "C4"sv;
|
||||||
|
case ETexelFormat::C8:
|
||||||
|
return "C8"sv;
|
||||||
|
case ETexelFormat::C14X2:
|
||||||
|
return "C14X2"sv;
|
||||||
|
case ETexelFormat::RGB565:
|
||||||
|
return "RGB565"sv;
|
||||||
|
case ETexelFormat::RGB5A3:
|
||||||
|
return "RGB5A3"sv;
|
||||||
|
case ETexelFormat::RGBA8:
|
||||||
|
return "RGBA8"sv;
|
||||||
|
case ETexelFormat::CMPR:
|
||||||
|
return "CMPR"sv;
|
||||||
|
case ETexelFormat::RGBA8PC:
|
||||||
|
return "RGBA8PC"sv;
|
||||||
|
case ETexelFormat::C8PC:
|
||||||
|
return "C8PC"sv;
|
||||||
|
case ETexelFormat::CMPRPC:
|
||||||
|
return "CMPRPC"sv;
|
||||||
|
case ETexelFormat::CMPRPCA:
|
||||||
|
return "CMPRPCA"sv;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CTexture::CTexture(ETexelFormat fmt, s16 w, s16 h, s32 mips) : x0_fmt(fmt), x4_w(w), x6_h(h), x8_mips(mips) {
|
CTexture::CTexture(ETexelFormat fmt, s16 w, s16 h, s32 mips) : x0_fmt(fmt), x4_w(w), x6_h(h), x8_mips(mips) {
|
||||||
|
@ -731,8 +712,8 @@ CTexture::CTexture(ETexelFormat fmt, s16 w, s16 h, s32 mips) : x0_fmt(fmt), x4_w
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
CTexture::CTexture(std::unique_ptr<u8[]>&& in, u32 length, bool otex, const CTextureInfo* inf) {
|
CTexture::CTexture(std::unique_ptr<u8[]>&& in, u32 length, bool otex, const CTextureInfo* inf, CAssetId id)
|
||||||
m_textureInfo = inf;
|
: m_textureInfo(inf) {
|
||||||
std::unique_ptr<u8[]> owned = std::move(in);
|
std::unique_ptr<u8[]> owned = std::move(in);
|
||||||
athena::io::MemoryReader r(owned.get(), length);
|
athena::io::MemoryReader r(owned.get(), length);
|
||||||
x0_fmt = ETexelFormat(r.readUint32Big());
|
x0_fmt = ETexelFormat(r.readUint32Big());
|
||||||
|
@ -740,52 +721,53 @@ CTexture::CTexture(std::unique_ptr<u8[]>&& in, u32 length, bool otex, const CTex
|
||||||
x6_h = r.readUint16Big();
|
x6_h = r.readUint16Big();
|
||||||
x8_mips = r.readUint32Big();
|
x8_mips = r.readUint32Big();
|
||||||
|
|
||||||
|
auto label = fmt::format(FMT_STRING("TXTR {:08X} ({})"), id.Value(), TextureFormatString(x0_fmt));
|
||||||
switch (x0_fmt) {
|
switch (x0_fmt) {
|
||||||
case ETexelFormat::I4:
|
case ETexelFormat::I4:
|
||||||
BuildI4FromGCN(r);
|
BuildI4FromGCN(r, label);
|
||||||
break;
|
break;
|
||||||
case ETexelFormat::I8:
|
case ETexelFormat::I8:
|
||||||
BuildI8FromGCN(r);
|
BuildI8FromGCN(r, label);
|
||||||
break;
|
break;
|
||||||
case ETexelFormat::IA4:
|
case ETexelFormat::IA4:
|
||||||
BuildIA4FromGCN(r);
|
BuildIA4FromGCN(r, label);
|
||||||
break;
|
break;
|
||||||
case ETexelFormat::IA8:
|
case ETexelFormat::IA8:
|
||||||
BuildIA8FromGCN(r);
|
BuildIA8FromGCN(r, label);
|
||||||
break;
|
break;
|
||||||
case ETexelFormat::C4:
|
case ETexelFormat::C4:
|
||||||
BuildC4FromGCN(r);
|
BuildC4FromGCN(r, label);
|
||||||
break;
|
break;
|
||||||
case ETexelFormat::C8:
|
case ETexelFormat::C8:
|
||||||
BuildC8FromGCN(r);
|
BuildC8FromGCN(r, label);
|
||||||
break;
|
break;
|
||||||
case ETexelFormat::C14X2:
|
case ETexelFormat::C14X2:
|
||||||
BuildC14X2FromGCN(r);
|
BuildC14X2FromGCN(r, label);
|
||||||
break;
|
break;
|
||||||
case ETexelFormat::RGB565:
|
case ETexelFormat::RGB565:
|
||||||
BuildRGB565FromGCN(r);
|
BuildRGB565FromGCN(r, label);
|
||||||
break;
|
break;
|
||||||
case ETexelFormat::RGB5A3:
|
case ETexelFormat::RGB5A3:
|
||||||
BuildRGB5A3FromGCN(r);
|
BuildRGB5A3FromGCN(r, label);
|
||||||
break;
|
break;
|
||||||
case ETexelFormat::RGBA8:
|
case ETexelFormat::RGBA8:
|
||||||
BuildRGBA8FromGCN(r);
|
BuildRGBA8FromGCN(r, label);
|
||||||
break;
|
break;
|
||||||
case ETexelFormat::CMPR:
|
case ETexelFormat::CMPR:
|
||||||
BuildDXT1FromGCN(r);
|
BuildDXT1FromGCN(r, label);
|
||||||
break;
|
break;
|
||||||
case ETexelFormat::RGBA8PC:
|
case ETexelFormat::RGBA8PC:
|
||||||
BuildRGBA8(owned.get() + 12, length - 12);
|
BuildRGBA8(owned.get() + 12, length - 12, label);
|
||||||
break;
|
break;
|
||||||
case ETexelFormat::C8PC:
|
case ETexelFormat::C8PC:
|
||||||
BuildC8(owned.get() + 12, length - 12);
|
BuildC8(owned.get() + 12, length - 12, label);
|
||||||
otex = true;
|
otex = true;
|
||||||
break;
|
break;
|
||||||
case ETexelFormat::CMPRPC:
|
case ETexelFormat::CMPRPC:
|
||||||
BuildDXT1(owned.get() + 12, length - 12);
|
BuildDXT1(owned.get() + 12, length - 12, label);
|
||||||
break;
|
break;
|
||||||
case ETexelFormat::CMPRPCA:
|
case ETexelFormat::CMPRPCA:
|
||||||
BuildDXT3(owned.get() + 12, length - 12);
|
BuildDXT3(owned.get() + 12, length - 12, label);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Log.report(logvisor::Fatal, FMT_STRING("invalid texture type {} for boo"), int(x0_fmt));
|
Log.report(logvisor::Fatal, FMT_STRING("invalid texture type {} for boo"), int(x0_fmt));
|
||||||
|
@ -881,12 +863,12 @@ std::unique_ptr<u8[]> CTexture::BuildMemoryCardTex(u32& sizeOut, ETexelFormat& f
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
const boo::ObjToken<boo::ITexture>& CTexture::GetFontTexture(EFontType tp) {
|
const std::shared_ptr<aurora::TextureHandle>& CTexture::GetFontTexture(EFontType tp) {
|
||||||
if (m_ftype != tp && x0_fmt == ETexelFormat::C8PC) {
|
if (m_ftype != tp && x0_fmt == ETexelFormat::C8PC) {
|
||||||
m_ftype = tp;
|
m_ftype = tp;
|
||||||
BuildC8Font(m_otex.get() + 12, m_ftype);
|
BuildC8Font(m_otex.get() + 12, m_ftype, "Font (TODO)"sv);
|
||||||
}
|
}
|
||||||
return m_booTex;
|
return m_tex;
|
||||||
}
|
}
|
||||||
|
|
||||||
CFactoryFnReturn FTextureFactory(const metaforce::SObjectTag& tag, std::unique_ptr<u8[]>&& in, u32 len,
|
CFactoryFnReturn FTextureFactory(const metaforce::SObjectTag& tag, std::unique_ptr<u8[]>&& in, u32 len,
|
||||||
|
@ -896,7 +878,7 @@ CFactoryFnReturn FTextureFactory(const metaforce::SObjectTag& tag, std::unique_p
|
||||||
if (g_TextureCache)
|
if (g_TextureCache)
|
||||||
inf = g_TextureCache->GetTextureInfo(tag.id);
|
inf = g_TextureCache->GetTextureInfo(tag.id);
|
||||||
return TToken<CTexture>::GetIObjObjectFor(
|
return TToken<CTexture>::GetIObjObjectFor(
|
||||||
std::make_unique<CTexture>(std::move(in), len, u32Owned == SBIG('OTEX'), inf));
|
std::make_unique<CTexture>(std::move(in), len, u32Owned == SBIG('OTEX'), inf, tag.id));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace metaforce
|
} // namespace metaforce
|
||||||
|
|
|
@ -4,35 +4,35 @@
|
||||||
|
|
||||||
#include "Runtime/Graphics/CGraphics.hpp"
|
#include "Runtime/Graphics/CGraphics.hpp"
|
||||||
|
|
||||||
#include <hecl/Pipeline.hpp>
|
//#include <hecl/Pipeline.hpp>
|
||||||
#include <zeus/CAABox.hpp>
|
#include <zeus/CAABox.hpp>
|
||||||
|
|
||||||
namespace metaforce {
|
namespace metaforce {
|
||||||
|
|
||||||
static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
|
//static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
|
||||||
static boo::ObjToken<boo::IShaderPipeline> s_zOnlyPipeline;
|
//static boo::ObjToken<boo::IShaderPipeline> s_zOnlyPipeline;
|
||||||
|
|
||||||
void CAABoxShader::Initialize() {
|
void CAABoxShader::Initialize() {
|
||||||
s_Pipeline = hecl::conv->convert(Shader_CAABoxShader{});
|
// s_Pipeline = hecl::conv->convert(Shader_CAABoxShader{});
|
||||||
s_zOnlyPipeline = hecl::conv->convert(Shader_CAABoxShaderZOnly{});
|
// s_zOnlyPipeline = hecl::conv->convert(Shader_CAABoxShaderZOnly{});
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAABoxShader::Shutdown() {
|
void CAABoxShader::Shutdown() {
|
||||||
s_Pipeline.reset();
|
// s_Pipeline.reset();
|
||||||
s_zOnlyPipeline.reset();
|
// s_zOnlyPipeline.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
CAABoxShader::CAABoxShader(bool zOnly) {
|
CAABoxShader::CAABoxShader(bool zOnly) {
|
||||||
CGraphics::CommitResources([this, zOnly](boo::IGraphicsDataFactory::Context& ctx) {
|
// CGraphics::CommitResources([this, zOnly](boo::IGraphicsDataFactory::Context& ctx) {
|
||||||
m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(zeus::CVector3f), 34);
|
// m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(zeus::CVector3f), 34);
|
||||||
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
|
// 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::ObjToken<boo::IGraphicsBuffer>, 1> bufs{m_uniBuf.get()};
|
||||||
constexpr std::array<boo::PipelineStage, 1> stages{boo::PipelineStage::Vertex};
|
// constexpr std::array<boo::PipelineStage, 1> stages{boo::PipelineStage::Vertex};
|
||||||
m_dataBind =
|
// m_dataBind =
|
||||||
ctx.newShaderDataBinding(zOnly ? s_zOnlyPipeline : s_Pipeline, m_vbo.get(), nullptr, nullptr, bufs.size(),
|
// ctx.newShaderDataBinding(zOnly ? s_zOnlyPipeline : s_Pipeline, m_vbo.get(), nullptr, nullptr, bufs.size(),
|
||||||
bufs.data(), stages.data(), nullptr, nullptr, 0, nullptr, nullptr, nullptr);
|
// bufs.data(), stages.data(), nullptr, nullptr, 0, nullptr, nullptr, nullptr);
|
||||||
return true;
|
// return true;
|
||||||
} BooTrace);
|
// } BooTrace);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAABoxShader::setAABB(const zeus::CAABox& aabb) {
|
void CAABoxShader::setAABB(const zeus::CAABox& aabb) {
|
||||||
|
@ -62,7 +62,7 @@ void CAABoxShader::setAABB(const zeus::CAABox& aabb) {
|
||||||
{aabb.max.x(), aabb.max.y(), aabb.min.z()},
|
{aabb.max.x(), aabb.max.y(), aabb.min.z()},
|
||||||
}};
|
}};
|
||||||
|
|
||||||
m_vbo->load(vboData.data(), sizeof(vboData));
|
// m_vbo->load(vboData.data(), sizeof(vboData));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAABoxShader::draw(const zeus::CColor& color) {
|
void CAABoxShader::draw(const zeus::CColor& color) {
|
||||||
|
@ -70,10 +70,10 @@ void CAABoxShader::draw(const zeus::CColor& color) {
|
||||||
|
|
||||||
m_uniform.m_xf = CGraphics::GetPerspectiveProjectionMatrix(true) * CGraphics::g_GXModelView.toMatrix4f();
|
m_uniform.m_xf = CGraphics::GetPerspectiveProjectionMatrix(true) * CGraphics::g_GXModelView.toMatrix4f();
|
||||||
m_uniform.m_color = color;
|
m_uniform.m_color = color;
|
||||||
m_uniBuf->load(&m_uniform, sizeof(Uniform));
|
// m_uniBuf->load(&m_uniform, sizeof(Uniform));
|
||||||
|
//
|
||||||
CGraphics::SetShaderDataBinding(m_dataBind);
|
// CGraphics::SetShaderDataBinding(m_dataBind);
|
||||||
CGraphics::DrawArray(0, 34);
|
// CGraphics::DrawArray(0, 34);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace metaforce
|
} // namespace metaforce
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
//#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
||||||
|
|
||||||
#include <zeus/CColor.hpp>
|
#include <zeus/CColor.hpp>
|
||||||
#include <zeus/CMatrix4f.hpp>
|
#include <zeus/CMatrix4f.hpp>
|
||||||
|
@ -16,9 +16,9 @@ class CAABoxShader {
|
||||||
zeus::CMatrix4f m_xf;
|
zeus::CMatrix4f m_xf;
|
||||||
zeus::CColor m_color;
|
zeus::CColor m_color;
|
||||||
};
|
};
|
||||||
boo::ObjToken<boo::IGraphicsBufferD> m_vbo;
|
// boo::ObjToken<boo::IGraphicsBufferD> m_vbo;
|
||||||
boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
|
// boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
|
||||||
boo::ObjToken<boo::IShaderDataBinding> m_dataBind;
|
// boo::ObjToken<boo::IShaderDataBinding> m_dataBind;
|
||||||
Uniform m_uniform;
|
Uniform m_uniform;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
#include "Runtime/Graphics/CGraphics.hpp"
|
#include "Runtime/Graphics/CGraphics.hpp"
|
||||||
|
|
||||||
#include <hecl/Pipeline.hpp>
|
//#include <hecl/Pipeline.hpp>
|
||||||
#include <zeus/CVector2f.hpp>
|
#include <zeus/CVector2f.hpp>
|
||||||
|
|
||||||
namespace metaforce {
|
namespace metaforce {
|
||||||
|
@ -16,24 +16,28 @@ struct Vert {
|
||||||
zeus::CVector2f m_uv;
|
zeus::CVector2f m_uv;
|
||||||
};
|
};
|
||||||
|
|
||||||
boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
|
//boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
|
||||||
} // Anonymous namespace
|
} // Anonymous namespace
|
||||||
|
|
||||||
void CCameraBlurFilter::Initialize() { s_Pipeline = hecl::conv->convert(Shader_CCameraBlurFilter{}); }
|
void CCameraBlurFilter::Initialize() {
|
||||||
|
// s_Pipeline = hecl::conv->convert(Shader_CCameraBlurFilter{});
|
||||||
|
}
|
||||||
|
|
||||||
void CCameraBlurFilter::Shutdown() { s_Pipeline.reset(); }
|
void CCameraBlurFilter::Shutdown() {
|
||||||
|
// s_Pipeline.reset();
|
||||||
|
}
|
||||||
|
|
||||||
CCameraBlurFilter::CCameraBlurFilter() {
|
CCameraBlurFilter::CCameraBlurFilter() {
|
||||||
CGraphics::CommitResources([this](boo::IGraphicsDataFactory::Context& ctx) {
|
// CGraphics::CommitResources([this](boo::IGraphicsDataFactory::Context& ctx) {
|
||||||
m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, 32, 4);
|
// m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, 32, 4);
|
||||||
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
|
// 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::ObjToken<boo::IGraphicsBuffer>, 1> bufs{m_uniBuf.get()};
|
||||||
constexpr std::array stages{boo::PipelineStage::Vertex};
|
// constexpr std::array stages{boo::PipelineStage::Vertex};
|
||||||
const std::array<boo::ObjToken<boo::ITexture>, 1> texs{CGraphics::g_SpareTexture.get()};
|
// const std::array<boo::ObjToken<boo::ITexture>, 1> texs{CGraphics::g_SpareTexture.get()};
|
||||||
m_dataBind = ctx.newShaderDataBinding(s_Pipeline, m_vbo.get(), nullptr, nullptr, bufs.size(), bufs.data(),
|
// m_dataBind = ctx.newShaderDataBinding(s_Pipeline, m_vbo.get(), nullptr, nullptr, bufs.size(), bufs.data(),
|
||||||
stages.data(), nullptr, nullptr, texs.size(), texs.data(), nullptr, nullptr);
|
// stages.data(), nullptr, nullptr, texs.size(), texs.data(), nullptr, nullptr);
|
||||||
return true;
|
// return true;
|
||||||
} BooTrace);
|
// } BooTrace);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCameraBlurFilter::draw(float amount, bool clearDepth) {
|
void CCameraBlurFilter::draw(float amount, bool clearDepth) {
|
||||||
|
@ -58,7 +62,7 @@ void CCameraBlurFilter::draw(float amount, bool clearDepth) {
|
||||||
{{1.0, -1.0}, {xBias + xFac, yBias}},
|
{{1.0, -1.0}, {xBias + xFac, yBias}},
|
||||||
{{1.0, 1.0}, {xBias + xFac, yBias + yFac}},
|
{{1.0, 1.0}, {xBias + xFac, yBias + yFac}},
|
||||||
}};
|
}};
|
||||||
m_vbo->load(verts.data(), sizeof(verts));
|
// m_vbo->load(verts.data(), sizeof(verts));
|
||||||
|
|
||||||
for (size_t i = 0; i < m_uniform.m_uv.size(); ++i) {
|
for (size_t i = 0; i < m_uniform.m_uv.size(); ++i) {
|
||||||
auto tmp = static_cast<float>(i);
|
auto tmp = static_cast<float>(i);
|
||||||
|
@ -75,10 +79,10 @@ void CCameraBlurFilter::draw(float amount, bool clearDepth) {
|
||||||
m_uniform.m_uv[i][1] = amtY * yFac;
|
m_uniform.m_uv[i][1] = amtY * yFac;
|
||||||
}
|
}
|
||||||
m_uniform.m_opacity = std::min(amount / 2.f, 1.f);
|
m_uniform.m_opacity = std::min(amount / 2.f, 1.f);
|
||||||
m_uniBuf->load(&m_uniform, sizeof(m_uniform));
|
// m_uniBuf->load(&m_uniform, sizeof(m_uniform));
|
||||||
|
|
||||||
CGraphics::SetShaderDataBinding(m_dataBind);
|
// CGraphics::SetShaderDataBinding(m_dataBind);
|
||||||
CGraphics::DrawArray(0, 4);
|
// CGraphics::DrawArray(0, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace metaforce
|
} // namespace metaforce
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
//#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
||||||
#include <zeus/CVector4f.hpp>
|
#include <zeus/CVector4f.hpp>
|
||||||
|
|
||||||
namespace metaforce {
|
namespace metaforce {
|
||||||
|
@ -12,9 +12,9 @@ class CCameraBlurFilter {
|
||||||
float m_opacity = 1.f;
|
float m_opacity = 1.f;
|
||||||
};
|
};
|
||||||
|
|
||||||
boo::ObjToken<boo::IGraphicsBufferD> m_vbo;
|
// boo::ObjToken<boo::IGraphicsBufferD> m_vbo;
|
||||||
boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
|
// boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
|
||||||
boo::ObjToken<boo::IShaderDataBinding> m_dataBind;
|
// boo::ObjToken<boo::IShaderDataBinding> m_dataBind;
|
||||||
Uniform m_uniform;
|
Uniform m_uniform;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -5,61 +5,61 @@
|
||||||
#include "Runtime/Camera/CCameraFilter.hpp"
|
#include "Runtime/Camera/CCameraFilter.hpp"
|
||||||
#include "Runtime/Graphics/CGraphics.hpp"
|
#include "Runtime/Graphics/CGraphics.hpp"
|
||||||
|
|
||||||
#include <hecl/Pipeline.hpp>
|
//#include <hecl/Pipeline.hpp>
|
||||||
|
|
||||||
namespace metaforce {
|
namespace metaforce {
|
||||||
|
|
||||||
static boo::ObjToken<boo::IShaderPipeline> s_AlphaPipeline;
|
//static boo::ObjToken<boo::IShaderPipeline> s_AlphaPipeline;
|
||||||
static boo::ObjToken<boo::IShaderPipeline> s_AddPipeline;
|
//static boo::ObjToken<boo::IShaderPipeline> s_AddPipeline;
|
||||||
static boo::ObjToken<boo::IShaderPipeline> s_MultPipeline;
|
//static boo::ObjToken<boo::IShaderPipeline> s_MultPipeline;
|
||||||
|
|
||||||
void CColoredQuadFilter::Initialize() {
|
void CColoredQuadFilter::Initialize() {
|
||||||
s_AlphaPipeline = hecl::conv->convert(Shader_CColoredQuadFilter{});
|
// s_AlphaPipeline = hecl::conv->convert(Shader_CColoredQuadFilter{});
|
||||||
s_AddPipeline = hecl::conv->convert(Shader_CColoredQuadFilterAdd{});
|
// s_AddPipeline = hecl::conv->convert(Shader_CColoredQuadFilterAdd{});
|
||||||
s_MultPipeline = hecl::conv->convert(Shader_CColoredQuadFilterMul{});
|
// s_MultPipeline = hecl::conv->convert(Shader_CColoredQuadFilterMul{});
|
||||||
}
|
}
|
||||||
|
|
||||||
void CColoredQuadFilter::Shutdown() {
|
void CColoredQuadFilter::Shutdown() {
|
||||||
s_AlphaPipeline.reset();
|
// s_AlphaPipeline.reset();
|
||||||
s_AddPipeline.reset();
|
// s_AddPipeline.reset();
|
||||||
s_MultPipeline.reset();
|
// s_MultPipeline.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
static boo::ObjToken<boo::IShaderPipeline> SelectPipeline(EFilterType type) {
|
//static boo::ObjToken<boo::IShaderPipeline> SelectPipeline(EFilterType type) {
|
||||||
switch (type) {
|
// switch (type) {
|
||||||
case EFilterType::Blend:
|
// case EFilterType::Blend:
|
||||||
return s_AlphaPipeline;
|
// return s_AlphaPipeline;
|
||||||
case EFilterType::Add:
|
// case EFilterType::Add:
|
||||||
return s_AddPipeline;
|
// return s_AddPipeline;
|
||||||
case EFilterType::Multiply:
|
// case EFilterType::Multiply:
|
||||||
return s_MultPipeline;
|
// return s_MultPipeline;
|
||||||
default:
|
// default:
|
||||||
return s_AlphaPipeline;
|
// return s_AlphaPipeline;
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
||||||
CColoredQuadFilter::CColoredQuadFilter(EFilterType type) {
|
CColoredQuadFilter::CColoredQuadFilter(EFilterType type) {
|
||||||
CGraphics::CommitResources([this, type](boo::IGraphicsDataFactory::Context& ctx) {
|
// CGraphics::CommitResources([this, type](boo::IGraphicsDataFactory::Context& ctx) {
|
||||||
struct Vert {
|
// struct Vert {
|
||||||
zeus::CVector2f m_pos;
|
// zeus::CVector2f m_pos;
|
||||||
};
|
// };
|
||||||
|
//
|
||||||
const std::array<Vert, 4> verts{{
|
// const std::array<Vert, 4> verts{{
|
||||||
{{0.0, 0.0}},
|
// {{0.0, 0.0}},
|
||||||
{{0.0, 1.0}},
|
// {{0.0, 1.0}},
|
||||||
{{1.0, 0.0}},
|
// {{1.0, 0.0}},
|
||||||
{{1.0, 1.0}},
|
// {{1.0, 1.0}},
|
||||||
}};
|
// }};
|
||||||
|
//
|
||||||
m_vbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, verts.data(), 16, verts.size());
|
// m_vbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, verts.data(), 16, verts.size());
|
||||||
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
|
// 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::ObjToken<boo::IGraphicsBuffer>, 1> bufs{m_uniBuf.get()};
|
||||||
constexpr std::array<boo::PipelineStage, 1> stages{boo::PipelineStage::Vertex};
|
// 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(),
|
// m_dataBind = ctx.newShaderDataBinding(SelectPipeline(type), m_vbo.get(), nullptr, nullptr, bufs.size(), bufs.data(),
|
||||||
stages.data(), nullptr, nullptr, 0, nullptr, nullptr, nullptr);
|
// stages.data(), nullptr, nullptr, 0, nullptr, nullptr, nullptr);
|
||||||
return true;
|
// return true;
|
||||||
} BooTrace);
|
// } BooTrace);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CColoredQuadFilter::draw(const zeus::CColor& color, const zeus::CRectangle& rect) {
|
void CColoredQuadFilter::draw(const zeus::CColor& color, const zeus::CRectangle& rect) {
|
||||||
|
@ -70,10 +70,10 @@ 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][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[3][1] = rect.position.y() * 2.f - 1.f;
|
||||||
m_uniform.m_color = color;
|
m_uniform.m_color = color;
|
||||||
m_uniBuf->load(&m_uniform, sizeof(m_uniform));
|
// m_uniBuf->load(&m_uniform, sizeof(m_uniform));
|
||||||
|
//
|
||||||
CGraphics::SetShaderDataBinding(m_dataBind);
|
// CGraphics::SetShaderDataBinding(m_dataBind);
|
||||||
CGraphics::DrawArray(0, 4);
|
// CGraphics::DrawArray(0, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWideScreenFilter::draw(const zeus::CColor& color, float t) {
|
void CWideScreenFilter::draw(const zeus::CColor& color, float t) {
|
||||||
|
@ -92,12 +92,12 @@ float CWideScreenFilter::SetViewportToMatch(float t) {
|
||||||
if (g_Viewport.aspect < 1.7777f) {
|
if (g_Viewport.aspect < 1.7777f) {
|
||||||
float targetHeight = g_Viewport.x8_width / 1.7777f;
|
float targetHeight = g_Viewport.x8_width / 1.7777f;
|
||||||
float delta = (g_Viewport.xc_height - targetHeight) * t / 2.f;
|
float delta = (g_Viewport.xc_height - targetHeight) * t / 2.f;
|
||||||
boo::SWindowRect rect = {};
|
// boo::SWindowRect rect = {};
|
||||||
rect.size[0] = g_Viewport.x8_width;
|
// rect.size[0] = g_Viewport.x8_width;
|
||||||
rect.size[1] = g_Viewport.xc_height - delta * 2.f;
|
// rect.size[1] = g_Viewport.xc_height - delta * 2.f;
|
||||||
rect.location[1] = delta;
|
// rect.location[1] = delta;
|
||||||
CGraphics::g_CroppedViewport = rect;
|
// CGraphics::g_CroppedViewport = rect;
|
||||||
CGraphics::g_BooMainCommandQueue->setViewport(rect);
|
// CGraphics::g_BooMainCommandQueue->setViewport(rect);
|
||||||
return 1.7777f;
|
return 1.7777f;
|
||||||
} else {
|
} else {
|
||||||
SetViewportToFull();
|
SetViewportToFull();
|
||||||
|
@ -106,11 +106,11 @@ float CWideScreenFilter::SetViewportToMatch(float t) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWideScreenFilter::SetViewportToFull() {
|
void CWideScreenFilter::SetViewportToFull() {
|
||||||
boo::SWindowRect rect = {};
|
// boo::SWindowRect rect = {};
|
||||||
rect.size[0] = g_Viewport.x8_width;
|
// rect.size[0] = g_Viewport.x8_width;
|
||||||
rect.size[1] = g_Viewport.xc_height;
|
// rect.size[1] = g_Viewport.xc_height;
|
||||||
CGraphics::g_CroppedViewport = rect;
|
// CGraphics::g_CroppedViewport = rect;
|
||||||
CGraphics::g_BooMainCommandQueue->setViewport(rect);
|
// CGraphics::g_BooMainCommandQueue->setViewport(rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace metaforce
|
} // namespace metaforce
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
#include "Runtime/CToken.hpp"
|
#include "Runtime/CToken.hpp"
|
||||||
|
|
||||||
#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
//#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
||||||
|
|
||||||
#include <zeus/CColor.hpp>
|
#include <zeus/CColor.hpp>
|
||||||
#include <zeus/CMatrix4f.hpp>
|
#include <zeus/CMatrix4f.hpp>
|
||||||
|
@ -19,9 +19,9 @@ class CColoredQuadFilter {
|
||||||
zeus::CMatrix4f m_matrix;
|
zeus::CMatrix4f m_matrix;
|
||||||
zeus::CColor m_color;
|
zeus::CColor m_color;
|
||||||
};
|
};
|
||||||
boo::ObjToken<boo::IGraphicsBufferS> m_vbo;
|
// boo::ObjToken<boo::IGraphicsBufferS> m_vbo;
|
||||||
boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
|
// boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
|
||||||
boo::ObjToken<boo::IShaderDataBinding> m_dataBind;
|
// boo::ObjToken<boo::IShaderDataBinding> m_dataBind;
|
||||||
Uniform m_uniform;
|
Uniform m_uniform;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -6,84 +6,79 @@
|
||||||
#include "Runtime/Graphics/CBooRenderer.hpp"
|
#include "Runtime/Graphics/CBooRenderer.hpp"
|
||||||
#include "Runtime/Graphics/CGraphics.hpp"
|
#include "Runtime/Graphics/CGraphics.hpp"
|
||||||
|
|
||||||
#include <hecl/Pipeline.hpp>
|
//#include <hecl/Pipeline.hpp>
|
||||||
|
|
||||||
namespace metaforce {
|
namespace metaforce {
|
||||||
|
|
||||||
static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
|
//static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
|
||||||
static boo::ObjToken<boo::IShaderPipeline> s_AdditivePipeline;
|
//static boo::ObjToken<boo::IShaderPipeline> s_AdditivePipeline;
|
||||||
static boo::ObjToken<boo::IShaderPipeline> s_FullAdditivePipeline;
|
//static boo::ObjToken<boo::IShaderPipeline> s_FullAdditivePipeline;
|
||||||
static boo::ObjToken<boo::IShaderPipeline> s_SubtractivePipeline;
|
//static boo::ObjToken<boo::IShaderPipeline> s_SubtractivePipeline;
|
||||||
|
|
||||||
void CColoredStripShader::Initialize() {
|
void CColoredStripShader::Initialize() {
|
||||||
s_Pipeline = hecl::conv->convert(Shader_CColoredStripShader{});
|
// s_Pipeline = hecl::conv->convert(Shader_CColoredStripShader{});
|
||||||
s_AdditivePipeline = hecl::conv->convert(Shader_CColoredStripShaderAdditive{});
|
// s_AdditivePipeline = hecl::conv->convert(Shader_CColoredStripShaderAdditive{});
|
||||||
s_FullAdditivePipeline = hecl::conv->convert(Shader_CColoredStripShaderFullAdditive{});
|
// s_FullAdditivePipeline = hecl::conv->convert(Shader_CColoredStripShaderFullAdditive{});
|
||||||
s_SubtractivePipeline = hecl::conv->convert(Shader_CColoredStripShaderSubtractive{});
|
// s_SubtractivePipeline = hecl::conv->convert(Shader_CColoredStripShaderSubtractive{});
|
||||||
}
|
}
|
||||||
|
|
||||||
void CColoredStripShader::Shutdown() {
|
void CColoredStripShader::Shutdown() {
|
||||||
s_Pipeline.reset();
|
// s_Pipeline.reset();
|
||||||
s_AdditivePipeline.reset();
|
// s_AdditivePipeline.reset();
|
||||||
s_FullAdditivePipeline.reset();
|
// s_FullAdditivePipeline.reset();
|
||||||
s_SubtractivePipeline.reset();
|
// s_SubtractivePipeline.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
static const boo::ObjToken<boo::IShaderPipeline>& SelectPipeline(CColoredStripShader::Mode mode) {
|
//static const boo::ObjToken<boo::IShaderPipeline>& SelectPipeline(CColoredStripShader::Mode mode) {
|
||||||
switch (mode) {
|
// switch (mode) {
|
||||||
case CColoredStripShader::Mode::Alpha:
|
// case CColoredStripShader::Mode::Alpha:
|
||||||
default:
|
// default:
|
||||||
return s_Pipeline;
|
// return s_Pipeline;
|
||||||
case CColoredStripShader::Mode::Additive:
|
// case CColoredStripShader::Mode::Additive:
|
||||||
return s_AdditivePipeline;
|
// return s_AdditivePipeline;
|
||||||
case CColoredStripShader::Mode::FullAdditive:
|
// case CColoredStripShader::Mode::FullAdditive:
|
||||||
return s_FullAdditivePipeline;
|
// return s_FullAdditivePipeline;
|
||||||
case CColoredStripShader::Mode::Subtractive:
|
// case CColoredStripShader::Mode::Subtractive:
|
||||||
return s_SubtractivePipeline;
|
// return s_SubtractivePipeline;
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
|
//void CColoredStripShader::BuildResources(boo::IGraphicsDataFactory::Context& ctx, size_t maxVerts, Mode mode,
|
||||||
|
// boo::ObjToken<boo::ITexture> tex) {
|
||||||
|
// m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(Vert), maxVerts);
|
||||||
|
// 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};
|
||||||
|
// std::array<boo::ObjToken<boo::ITexture>, 1> texs;
|
||||||
|
// if (tex) {
|
||||||
|
// texs[0] = tex;
|
||||||
|
// } else {
|
||||||
|
// texs[0] = g_Renderer->GetWhiteTexture();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// m_dataBind = ctx.newShaderDataBinding(SelectPipeline(mode), m_vbo.get(), nullptr, nullptr, bufs.size(), bufs.data(),
|
||||||
|
// stages.data(), nullptr, nullptr, texs.size(), texs.data(), nullptr, nullptr);
|
||||||
|
//}
|
||||||
|
|
||||||
void CColoredStripShader::BuildResources(boo::IGraphicsDataFactory::Context& ctx, size_t maxVerts, Mode mode,
|
CColoredStripShader::CColoredStripShader(size_t maxVerts, Mode mode, std::shared_ptr<aurora::TextureHandle> tex) {
|
||||||
boo::ObjToken<boo::ITexture> tex) {
|
// CGraphics::CommitResources([this, maxVerts, mode, tex](boo::IGraphicsDataFactory::Context& ctx) {
|
||||||
m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(Vert), maxVerts);
|
// BuildResources(ctx, maxVerts, mode, tex);
|
||||||
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
|
// return true;
|
||||||
|
// } BooTrace);
|
||||||
const std::array<boo::ObjToken<boo::IGraphicsBuffer>, 1> bufs{m_uniBuf.get()};
|
|
||||||
constexpr std::array<boo::PipelineStage, 1> stages{boo::PipelineStage::Vertex};
|
|
||||||
std::array<boo::ObjToken<boo::ITexture>, 1> texs;
|
|
||||||
if (tex) {
|
|
||||||
texs[0] = tex;
|
|
||||||
} else {
|
|
||||||
texs[0] = g_Renderer->GetWhiteTexture();
|
|
||||||
}
|
|
||||||
|
|
||||||
m_dataBind = ctx.newShaderDataBinding(SelectPipeline(mode), m_vbo.get(), nullptr, nullptr, bufs.size(), bufs.data(),
|
|
||||||
stages.data(), nullptr, nullptr, texs.size(), texs.data(), nullptr, nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
CColoredStripShader::CColoredStripShader(size_t maxVerts, Mode mode, boo::ObjToken<boo::ITexture> tex) {
|
|
||||||
CGraphics::CommitResources([this, maxVerts, mode, tex](boo::IGraphicsDataFactory::Context& ctx) {
|
|
||||||
BuildResources(ctx, maxVerts, mode, tex);
|
|
||||||
return true;
|
|
||||||
} BooTrace);
|
|
||||||
}
|
|
||||||
|
|
||||||
CColoredStripShader::CColoredStripShader(boo::IGraphicsDataFactory::Context& ctx, size_t maxVerts, Mode mode,
|
|
||||||
boo::ObjToken<boo::ITexture> tex) {
|
|
||||||
BuildResources(ctx, maxVerts, mode, tex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CColoredStripShader::draw(const zeus::CColor& color, size_t numVerts, const Vert* verts) {
|
void CColoredStripShader::draw(const zeus::CColor& color, size_t numVerts, const Vert* verts) {
|
||||||
SCOPED_GRAPHICS_DEBUG_GROUP("CColoredStripShader::draw", zeus::skMagenta);
|
SCOPED_GRAPHICS_DEBUG_GROUP("CColoredStripShader::draw", zeus::skMagenta);
|
||||||
|
|
||||||
m_vbo->load(verts, sizeof(Vert) * numVerts);
|
// m_vbo->load(verts, sizeof(Vert) * numVerts);
|
||||||
|
|
||||||
m_uniform.m_matrix = CGraphics::GetPerspectiveProjectionMatrix(true) * CGraphics::g_GXModelView.toMatrix4f();
|
m_uniform.m_matrix = CGraphics::GetPerspectiveProjectionMatrix(true) * CGraphics::g_GXModelView.toMatrix4f();
|
||||||
m_uniform.m_color = color;
|
m_uniform.m_color = color;
|
||||||
m_uniBuf->load(&m_uniform, sizeof(m_uniform));
|
// m_uniBuf->load(&m_uniform, sizeof(m_uniform));
|
||||||
|
//
|
||||||
CGraphics::SetShaderDataBinding(m_dataBind);
|
// CGraphics::SetShaderDataBinding(m_dataBind);
|
||||||
CGraphics::DrawArray(0, numVerts);
|
// CGraphics::DrawArray(0, numVerts);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace metaforce
|
} // namespace metaforce
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
#include "Runtime/Graphics/CGraphics.hpp"
|
||||||
|
|
||||||
#include <zeus/CColor.hpp>
|
#include <zeus/CColor.hpp>
|
||||||
#include <zeus/CMatrix4f.hpp>
|
#include <zeus/CMatrix4f.hpp>
|
||||||
|
@ -16,13 +16,13 @@ private:
|
||||||
zeus::CMatrix4f m_matrix;
|
zeus::CMatrix4f m_matrix;
|
||||||
zeus::CColor m_color;
|
zeus::CColor m_color;
|
||||||
};
|
};
|
||||||
boo::ObjToken<boo::IGraphicsBufferD> m_vbo;
|
// boo::ObjToken<boo::IGraphicsBufferD> m_vbo;
|
||||||
boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
|
// boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
|
||||||
boo::ObjToken<boo::IShaderDataBinding> m_dataBind;
|
// boo::ObjToken<boo::IShaderDataBinding> m_dataBind;
|
||||||
Uniform m_uniform;
|
Uniform m_uniform;
|
||||||
|
|
||||||
void BuildResources(boo::IGraphicsDataFactory::Context& ctx, size_t maxVerts, Mode mode,
|
// void BuildResources(boo::IGraphicsDataFactory::Context& ctx, size_t maxVerts, Mode mode,
|
||||||
boo::ObjToken<boo::ITexture> tex);
|
// boo::ObjToken<boo::ITexture> tex);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
struct Vert {
|
struct Vert {
|
||||||
|
@ -32,9 +32,7 @@ public:
|
||||||
};
|
};
|
||||||
static void Initialize();
|
static void Initialize();
|
||||||
static void Shutdown();
|
static void Shutdown();
|
||||||
CColoredStripShader(size_t maxVerts, Mode mode, boo::ObjToken<boo::ITexture> tex);
|
CColoredStripShader(size_t maxVerts, Mode mode, std::shared_ptr<aurora::TextureHandle> tex);
|
||||||
CColoredStripShader(boo::IGraphicsDataFactory::Context& ctx, size_t maxVerts, Mode mode,
|
|
||||||
boo::ObjToken<boo::ITexture> tex);
|
|
||||||
void draw(const zeus::CColor& color, size_t numVerts, const Vert* verts);
|
void draw(const zeus::CColor& color, size_t numVerts, const Vert* verts);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -4,69 +4,69 @@
|
||||||
|
|
||||||
#include "Runtime/Particle/CDecal.hpp"
|
#include "Runtime/Particle/CDecal.hpp"
|
||||||
|
|
||||||
#include <hecl/Pipeline.hpp>
|
//#include <hecl/Pipeline.hpp>
|
||||||
|
|
||||||
namespace metaforce {
|
namespace metaforce {
|
||||||
|
|
||||||
void CDecalShaders::Initialize() {
|
void CDecalShaders::Initialize() {
|
||||||
m_texZTestNoZWrite = hecl::conv->convert(Shader_CDecalShaderTexZTest{});
|
// m_texZTestNoZWrite = hecl::conv->convert(Shader_CDecalShaderTexZTest{});
|
||||||
m_texAdditiveZTest = hecl::conv->convert(Shader_CDecalShaderTexAdditiveZTest{});
|
// m_texAdditiveZTest = hecl::conv->convert(Shader_CDecalShaderTexAdditiveZTest{});
|
||||||
m_texRedToAlphaZTest = hecl::conv->convert(Shader_CDecalShaderTexRedToAlphaZTest{});
|
// m_texRedToAlphaZTest = hecl::conv->convert(Shader_CDecalShaderTexRedToAlphaZTest{});
|
||||||
m_noTexZTestNoZWrite = hecl::conv->convert(Shader_CDecalShaderNoTexZTest{});
|
// m_noTexZTestNoZWrite = hecl::conv->convert(Shader_CDecalShaderNoTexZTest{});
|
||||||
m_noTexAdditiveZTest = hecl::conv->convert(Shader_CDecalShaderNoTexAdditiveZTest{});
|
// m_noTexAdditiveZTest = hecl::conv->convert(Shader_CDecalShaderNoTexAdditiveZTest{});
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDecalShaders::Shutdown() {
|
void CDecalShaders::Shutdown() {
|
||||||
m_texZTestNoZWrite.reset();
|
// m_texZTestNoZWrite.reset();
|
||||||
m_texAdditiveZTest.reset();
|
// m_texAdditiveZTest.reset();
|
||||||
m_texRedToAlphaZTest.reset();
|
// m_texRedToAlphaZTest.reset();
|
||||||
m_noTexZTestNoZWrite.reset();
|
// m_noTexZTestNoZWrite.reset();
|
||||||
m_noTexAdditiveZTest.reset();
|
// m_noTexAdditiveZTest.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDecalShaders::BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, CQuadDecal& decal) {
|
void CDecalShaders::BuildShaderDataBinding(CQuadDecal& decal) {
|
||||||
boo::ObjToken<boo::IShaderPipeline> regPipeline;
|
// boo::ObjToken<boo::IShaderPipeline> regPipeline;
|
||||||
boo::ObjToken<boo::IShaderPipeline> redToAlphaPipeline;
|
// boo::ObjToken<boo::IShaderPipeline> redToAlphaPipeline;
|
||||||
|
|
||||||
if (decal.m_desc->x14_TEX) {
|
// if (decal.m_desc->x14_TEX) {
|
||||||
if (decal.m_desc->x18_ADD)
|
// if (decal.m_desc->x18_ADD)
|
||||||
regPipeline = m_texAdditiveZTest;
|
// regPipeline = m_texAdditiveZTest;
|
||||||
else
|
// else
|
||||||
regPipeline = m_texZTestNoZWrite;
|
// regPipeline = m_texZTestNoZWrite;
|
||||||
redToAlphaPipeline = m_texRedToAlphaZTest;
|
// redToAlphaPipeline = m_texRedToAlphaZTest;
|
||||||
} else {
|
// } else {
|
||||||
if (decal.m_desc->x18_ADD)
|
// if (decal.m_desc->x18_ADD)
|
||||||
regPipeline = m_noTexAdditiveZTest;
|
// regPipeline = m_noTexAdditiveZTest;
|
||||||
else
|
// else
|
||||||
regPipeline = m_noTexZTestNoZWrite;
|
// regPipeline = m_noTexZTestNoZWrite;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
const SQuadDescr* const desc = decal.m_desc;
|
// const SQuadDescr* const desc = decal.m_desc;
|
||||||
const CUVElement* const texr = desc->x14_TEX.get();
|
// const CUVElement* const texr = desc->x14_TEX.get();
|
||||||
size_t texCount = 0;
|
// size_t texCount = 0;
|
||||||
std::array<boo::ObjToken<boo::ITexture>, 1> textures;
|
// std::array<boo::ObjToken<boo::ITexture>, 1> textures;
|
||||||
|
//
|
||||||
if (texr != nullptr) {
|
// if (texr != nullptr) {
|
||||||
textures[0] = texr->GetValueTexture(0).GetObj()->GetBooTexture();
|
// textures[0] = texr->GetValueTexture(0).GetObj()->GetBooTexture();
|
||||||
texCount = 1;
|
// texCount = 1;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (!decal.m_instBuf) {
|
// if (!decal.m_instBuf) {
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
std::array<boo::ObjToken<boo::IGraphicsBuffer>, 1> uniforms{decal.m_uniformBuf.get()};
|
// std::array<boo::ObjToken<boo::IGraphicsBuffer>, 1> uniforms{decal.m_uniformBuf.get()};
|
||||||
|
//
|
||||||
if (regPipeline) {
|
// if (regPipeline) {
|
||||||
decal.m_normalDataBind =
|
// decal.m_normalDataBind =
|
||||||
ctx.newShaderDataBinding(regPipeline, nullptr, decal.m_instBuf.get(), nullptr, uniforms.size(), uniforms.data(),
|
// ctx.newShaderDataBinding(regPipeline, nullptr, decal.m_instBuf.get(), nullptr, uniforms.size(), uniforms.data(),
|
||||||
nullptr, texCount, textures.data(), nullptr, nullptr);
|
// nullptr, texCount, textures.data(), nullptr, nullptr);
|
||||||
}
|
// }
|
||||||
if (redToAlphaPipeline) {
|
// if (redToAlphaPipeline) {
|
||||||
decal.m_redToAlphaDataBind =
|
// decal.m_redToAlphaDataBind =
|
||||||
ctx.newShaderDataBinding(redToAlphaPipeline, nullptr, decal.m_instBuf.get(), nullptr, uniforms.size(),
|
// ctx.newShaderDataBinding(redToAlphaPipeline, nullptr, decal.m_instBuf.get(), nullptr, uniforms.size(),
|
||||||
uniforms.data(), nullptr, texCount, textures.data(), nullptr, nullptr);
|
// uniforms.data(), nullptr, texCount, textures.data(), nullptr, nullptr);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace metaforce
|
} // namespace metaforce
|
||||||
|
|
|
@ -1,23 +1,23 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
//#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
||||||
|
|
||||||
namespace metaforce {
|
namespace metaforce {
|
||||||
struct CQuadDecal;
|
struct CQuadDecal;
|
||||||
|
|
||||||
class CDecalShaders {
|
class CDecalShaders {
|
||||||
private:
|
private:
|
||||||
static inline boo::ObjToken<boo::IShaderPipeline> m_texZTestNoZWrite;
|
// static inline boo::ObjToken<boo::IShaderPipeline> m_texZTestNoZWrite;
|
||||||
static inline boo::ObjToken<boo::IShaderPipeline> m_texAdditiveZTest;
|
// static inline boo::ObjToken<boo::IShaderPipeline> m_texAdditiveZTest;
|
||||||
static inline boo::ObjToken<boo::IShaderPipeline> m_texRedToAlphaZTest;
|
// static inline boo::ObjToken<boo::IShaderPipeline> m_texRedToAlphaZTest;
|
||||||
|
//
|
||||||
static inline boo::ObjToken<boo::IShaderPipeline> m_noTexZTestNoZWrite;
|
// static inline boo::ObjToken<boo::IShaderPipeline> m_noTexZTestNoZWrite;
|
||||||
static inline boo::ObjToken<boo::IShaderPipeline> m_noTexAdditiveZTest;
|
// static inline boo::ObjToken<boo::IShaderPipeline> m_noTexAdditiveZTest;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void Initialize();
|
static void Initialize();
|
||||||
static void Shutdown();
|
static void Shutdown();
|
||||||
static void BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, CQuadDecal& decal);
|
static void BuildShaderDataBinding(CQuadDecal& decal);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace metaforce
|
} // namespace metaforce
|
||||||
|
|
|
@ -4,116 +4,116 @@
|
||||||
|
|
||||||
#include "Runtime/Particle/CElementGen.hpp"
|
#include "Runtime/Particle/CElementGen.hpp"
|
||||||
|
|
||||||
#include <hecl/Pipeline.hpp>
|
//#include <hecl/Pipeline.hpp>
|
||||||
|
|
||||||
namespace metaforce {
|
namespace metaforce {
|
||||||
|
|
||||||
void CElementGenShaders::Initialize() {
|
void CElementGenShaders::Initialize() {
|
||||||
m_texZTestZWrite = {hecl::conv->convert(Shader_CElementGenShaderTexZTestZWrite{}),
|
// m_texZTestZWrite = {hecl::conv->convert(Shader_CElementGenShaderTexZTestZWrite{}),
|
||||||
hecl::conv->convert(Shader_CElementGenShaderTexZTestZWrite{})};
|
// hecl::conv->convert(Shader_CElementGenShaderTexZTestZWrite{})};
|
||||||
m_texNoZTestZWrite = {hecl::conv->convert(Shader_CElementGenShaderTexNoZTestZWrite{}),
|
// m_texNoZTestZWrite = {hecl::conv->convert(Shader_CElementGenShaderTexNoZTestZWrite{}),
|
||||||
hecl::conv->convert(Shader_CElementGenShaderTexNoZTestZWriteAWrite{})};
|
// hecl::conv->convert(Shader_CElementGenShaderTexNoZTestZWriteAWrite{})};
|
||||||
m_texZTestNoZWrite = {hecl::conv->convert(Shader_CElementGenShaderTexZTestNoZWrite{}),
|
// m_texZTestNoZWrite = {hecl::conv->convert(Shader_CElementGenShaderTexZTestNoZWrite{}),
|
||||||
hecl::conv->convert(Shader_CElementGenShaderTexZTestNoZWriteAWrite{})};
|
// hecl::conv->convert(Shader_CElementGenShaderTexZTestNoZWriteAWrite{})};
|
||||||
m_texNoZTestNoZWrite = {hecl::conv->convert(Shader_CElementGenShaderTexNoZTestNoZWrite{}),
|
// m_texNoZTestNoZWrite = {hecl::conv->convert(Shader_CElementGenShaderTexNoZTestNoZWrite{}),
|
||||||
hecl::conv->convert(Shader_CElementGenShaderTexNoZTestNoZWriteAWrite{})};
|
// hecl::conv->convert(Shader_CElementGenShaderTexNoZTestNoZWriteAWrite{})};
|
||||||
m_texAdditiveZTest = {hecl::conv->convert(Shader_CElementGenShaderTexAdditiveZTest{}),
|
// m_texAdditiveZTest = {hecl::conv->convert(Shader_CElementGenShaderTexAdditiveZTest{}),
|
||||||
hecl::conv->convert(Shader_CElementGenShaderTexAdditiveZTestAWrite{})};
|
// hecl::conv->convert(Shader_CElementGenShaderTexAdditiveZTestAWrite{})};
|
||||||
m_texAdditiveNoZTest = {hecl::conv->convert(Shader_CElementGenShaderTexAdditiveNoZTest{}),
|
// m_texAdditiveNoZTest = {hecl::conv->convert(Shader_CElementGenShaderTexAdditiveNoZTest{}),
|
||||||
hecl::conv->convert(Shader_CElementGenShaderTexAdditiveNoZTestAWrite{})};
|
// hecl::conv->convert(Shader_CElementGenShaderTexAdditiveNoZTestAWrite{})};
|
||||||
m_texRedToAlphaZTest = {hecl::conv->convert(Shader_CElementGenShaderTexRedToAlphaZTest{}),
|
// m_texRedToAlphaZTest = {hecl::conv->convert(Shader_CElementGenShaderTexRedToAlphaZTest{}),
|
||||||
hecl::conv->convert(Shader_CElementGenShaderTexRedToAlphaZTestAWrite{})};
|
// hecl::conv->convert(Shader_CElementGenShaderTexRedToAlphaZTestAWrite{})};
|
||||||
m_texRedToAlphaNoZTest = {hecl::conv->convert(Shader_CElementGenShaderTexRedToAlphaNoZTest{}),
|
// m_texRedToAlphaNoZTest = {hecl::conv->convert(Shader_CElementGenShaderTexRedToAlphaNoZTest{}),
|
||||||
hecl::conv->convert(Shader_CElementGenShaderTexRedToAlphaNoZTestAWrite{})};
|
// hecl::conv->convert(Shader_CElementGenShaderTexRedToAlphaNoZTestAWrite{})};
|
||||||
m_texZTestNoZWriteSub = {hecl::conv->convert(Shader_CElementGenShaderTexZTestNoZWriteSub{}),
|
// m_texZTestNoZWriteSub = {hecl::conv->convert(Shader_CElementGenShaderTexZTestNoZWriteSub{}),
|
||||||
hecl::conv->convert(Shader_CElementGenShaderTexZTestNoZWriteSubAWrite{})};
|
// hecl::conv->convert(Shader_CElementGenShaderTexZTestNoZWriteSubAWrite{})};
|
||||||
m_texNoZTestNoZWriteSub = {hecl::conv->convert(Shader_CElementGenShaderTexNoZTestNoZWriteSub{}),
|
// m_texNoZTestNoZWriteSub = {hecl::conv->convert(Shader_CElementGenShaderTexNoZTestNoZWriteSub{}),
|
||||||
hecl::conv->convert(Shader_CElementGenShaderTexNoZTestNoZWriteSubAWrite{})};
|
// hecl::conv->convert(Shader_CElementGenShaderTexNoZTestNoZWriteSubAWrite{})};
|
||||||
m_texRedToAlphaZTestSub = {hecl::conv->convert(Shader_CElementGenShaderTexRedToAlphaZTestSub{}),
|
// m_texRedToAlphaZTestSub = {hecl::conv->convert(Shader_CElementGenShaderTexRedToAlphaZTestSub{}),
|
||||||
hecl::conv->convert(Shader_CElementGenShaderTexRedToAlphaZTestSubAWrite{})};
|
// hecl::conv->convert(Shader_CElementGenShaderTexRedToAlphaZTestSubAWrite{})};
|
||||||
m_texRedToAlphaNoZTestSub = {hecl::conv->convert(Shader_CElementGenShaderTexRedToAlphaNoZTestSub{}),
|
// m_texRedToAlphaNoZTestSub = {hecl::conv->convert(Shader_CElementGenShaderTexRedToAlphaNoZTestSub{}),
|
||||||
hecl::conv->convert(Shader_CElementGenShaderTexRedToAlphaNoZTestSubAWrite{})};
|
// hecl::conv->convert(Shader_CElementGenShaderTexRedToAlphaNoZTestSubAWrite{})};
|
||||||
|
//
|
||||||
m_indTexZWrite = {hecl::conv->convert(Shader_CElementGenShaderIndTexZWrite{}),
|
// m_indTexZWrite = {hecl::conv->convert(Shader_CElementGenShaderIndTexZWrite{}),
|
||||||
hecl::conv->convert(Shader_CElementGenShaderIndTexZWriteAWrite{})};
|
// hecl::conv->convert(Shader_CElementGenShaderIndTexZWriteAWrite{})};
|
||||||
m_indTexNoZWrite = {hecl::conv->convert(Shader_CElementGenShaderIndTexNoZWrite{}),
|
// m_indTexNoZWrite = {hecl::conv->convert(Shader_CElementGenShaderIndTexNoZWrite{}),
|
||||||
hecl::conv->convert(Shader_CElementGenShaderIndTexNoZWriteAWrite{})};
|
// hecl::conv->convert(Shader_CElementGenShaderIndTexNoZWriteAWrite{})};
|
||||||
m_indTexAdditive = {hecl::conv->convert(Shader_CElementGenShaderIndTexAdditive{}),
|
// m_indTexAdditive = {hecl::conv->convert(Shader_CElementGenShaderIndTexAdditive{}),
|
||||||
hecl::conv->convert(Shader_CElementGenShaderIndTexAdditiveAWrite{})};
|
// hecl::conv->convert(Shader_CElementGenShaderIndTexAdditiveAWrite{})};
|
||||||
|
//
|
||||||
m_cindTexZWrite = {hecl::conv->convert(Shader_CElementGenShaderCindTexZWrite{}),
|
// m_cindTexZWrite = {hecl::conv->convert(Shader_CElementGenShaderCindTexZWrite{}),
|
||||||
hecl::conv->convert(Shader_CElementGenShaderCindTexZWriteAWrite{})};
|
// hecl::conv->convert(Shader_CElementGenShaderCindTexZWriteAWrite{})};
|
||||||
m_cindTexNoZWrite = {hecl::conv->convert(Shader_CElementGenShaderCindTexNoZWrite{}),
|
// m_cindTexNoZWrite = {hecl::conv->convert(Shader_CElementGenShaderCindTexNoZWrite{}),
|
||||||
hecl::conv->convert(Shader_CElementGenShaderCindTexNoZWriteAWrite{})};
|
// hecl::conv->convert(Shader_CElementGenShaderCindTexNoZWriteAWrite{})};
|
||||||
m_cindTexAdditive = {hecl::conv->convert(Shader_CElementGenShaderCindTexAdditive{}),
|
// m_cindTexAdditive = {hecl::conv->convert(Shader_CElementGenShaderCindTexAdditive{}),
|
||||||
hecl::conv->convert(Shader_CElementGenShaderCindTexAdditiveAWrite{})};
|
// hecl::conv->convert(Shader_CElementGenShaderCindTexAdditiveAWrite{})};
|
||||||
|
//
|
||||||
m_noTexZTestZWrite = {hecl::conv->convert(Shader_CElementGenShaderNoTexZTestZWrite{}),
|
// m_noTexZTestZWrite = {hecl::conv->convert(Shader_CElementGenShaderNoTexZTestZWrite{}),
|
||||||
hecl::conv->convert(Shader_CElementGenShaderNoTexZTestZWriteAWrite{})};
|
// hecl::conv->convert(Shader_CElementGenShaderNoTexZTestZWriteAWrite{})};
|
||||||
m_noTexNoZTestZWrite = {hecl::conv->convert(Shader_CElementGenShaderNoTexNoZTestZWrite{}),
|
// m_noTexNoZTestZWrite = {hecl::conv->convert(Shader_CElementGenShaderNoTexNoZTestZWrite{}),
|
||||||
hecl::conv->convert(Shader_CElementGenShaderNoTexNoZTestZWriteAWrite{})};
|
// hecl::conv->convert(Shader_CElementGenShaderNoTexNoZTestZWriteAWrite{})};
|
||||||
m_noTexZTestNoZWrite = {hecl::conv->convert(Shader_CElementGenShaderNoTexZTestNoZWrite{}),
|
// m_noTexZTestNoZWrite = {hecl::conv->convert(Shader_CElementGenShaderNoTexZTestNoZWrite{}),
|
||||||
hecl::conv->convert(Shader_CElementGenShaderNoTexZTestNoZWriteAWrite{})};
|
// hecl::conv->convert(Shader_CElementGenShaderNoTexZTestNoZWriteAWrite{})};
|
||||||
m_noTexNoZTestNoZWrite = {hecl::conv->convert(Shader_CElementGenShaderNoTexNoZTestNoZWrite{}),
|
// m_noTexNoZTestNoZWrite = {hecl::conv->convert(Shader_CElementGenShaderNoTexNoZTestNoZWrite{}),
|
||||||
hecl::conv->convert(Shader_CElementGenShaderNoTexNoZTestNoZWriteAWrite{})};
|
// hecl::conv->convert(Shader_CElementGenShaderNoTexNoZTestNoZWriteAWrite{})};
|
||||||
m_noTexAdditiveZTest = {hecl::conv->convert(Shader_CElementGenShaderNoTexAdditiveZTest{}),
|
// m_noTexAdditiveZTest = {hecl::conv->convert(Shader_CElementGenShaderNoTexAdditiveZTest{}),
|
||||||
hecl::conv->convert(Shader_CElementGenShaderNoTexAdditiveZTestAWrite{})};
|
// hecl::conv->convert(Shader_CElementGenShaderNoTexAdditiveZTestAWrite{})};
|
||||||
m_noTexAdditiveNoZTest = {hecl::conv->convert(Shader_CElementGenShaderNoTexAdditiveNoZTest{}),
|
// m_noTexAdditiveNoZTest = {hecl::conv->convert(Shader_CElementGenShaderNoTexAdditiveNoZTest{}),
|
||||||
hecl::conv->convert(Shader_CElementGenShaderNoTexAdditiveNoZTestAWrite{})};
|
// hecl::conv->convert(Shader_CElementGenShaderNoTexAdditiveNoZTestAWrite{})};
|
||||||
}
|
}
|
||||||
|
|
||||||
void CElementGenShaders::Shutdown() {
|
void CElementGenShaders::Shutdown() {
|
||||||
for (auto& s : m_texZTestZWrite)
|
// for (auto& s : m_texZTestZWrite)
|
||||||
s.reset();
|
// s.reset();
|
||||||
for (auto& s : m_texNoZTestZWrite)
|
// for (auto& s : m_texNoZTestZWrite)
|
||||||
s.reset();
|
// s.reset();
|
||||||
for (auto& s : m_texZTestNoZWrite)
|
// for (auto& s : m_texZTestNoZWrite)
|
||||||
s.reset();
|
// s.reset();
|
||||||
for (auto& s : m_texNoZTestNoZWrite)
|
// for (auto& s : m_texNoZTestNoZWrite)
|
||||||
s.reset();
|
// s.reset();
|
||||||
for (auto& s : m_texAdditiveZTest)
|
// for (auto& s : m_texAdditiveZTest)
|
||||||
s.reset();
|
// s.reset();
|
||||||
for (auto& s : m_texAdditiveNoZTest)
|
// for (auto& s : m_texAdditiveNoZTest)
|
||||||
s.reset();
|
// s.reset();
|
||||||
for (auto& s : m_texRedToAlphaZTest)
|
// for (auto& s : m_texRedToAlphaZTest)
|
||||||
s.reset();
|
// s.reset();
|
||||||
for (auto& s : m_texRedToAlphaNoZTest)
|
// for (auto& s : m_texRedToAlphaNoZTest)
|
||||||
s.reset();
|
// s.reset();
|
||||||
for (auto& s : m_texZTestNoZWriteSub)
|
// for (auto& s : m_texZTestNoZWriteSub)
|
||||||
s.reset();
|
// s.reset();
|
||||||
for (auto& s : m_texNoZTestNoZWriteSub)
|
// for (auto& s : m_texNoZTestNoZWriteSub)
|
||||||
s.reset();
|
// s.reset();
|
||||||
for (auto& s : m_texRedToAlphaZTestSub)
|
// for (auto& s : m_texRedToAlphaZTestSub)
|
||||||
s.reset();
|
// s.reset();
|
||||||
for (auto& s : m_texRedToAlphaNoZTestSub)
|
// for (auto& s : m_texRedToAlphaNoZTestSub)
|
||||||
s.reset();
|
// s.reset();
|
||||||
|
//
|
||||||
for (auto& s : m_indTexZWrite)
|
// for (auto& s : m_indTexZWrite)
|
||||||
s.reset();
|
// s.reset();
|
||||||
for (auto& s : m_indTexNoZWrite)
|
// for (auto& s : m_indTexNoZWrite)
|
||||||
s.reset();
|
// s.reset();
|
||||||
for (auto& s : m_indTexAdditive)
|
// for (auto& s : m_indTexAdditive)
|
||||||
s.reset();
|
// s.reset();
|
||||||
|
//
|
||||||
for (auto& s : m_cindTexZWrite)
|
// for (auto& s : m_cindTexZWrite)
|
||||||
s.reset();
|
// s.reset();
|
||||||
for (auto& s : m_cindTexNoZWrite)
|
// for (auto& s : m_cindTexNoZWrite)
|
||||||
s.reset();
|
// s.reset();
|
||||||
for (auto& s : m_cindTexAdditive)
|
// for (auto& s : m_cindTexAdditive)
|
||||||
s.reset();
|
// s.reset();
|
||||||
|
//
|
||||||
for (auto& s : m_noTexZTestZWrite)
|
// for (auto& s : m_noTexZTestZWrite)
|
||||||
s.reset();
|
// s.reset();
|
||||||
for (auto& s : m_noTexNoZTestZWrite)
|
// for (auto& s : m_noTexNoZTestZWrite)
|
||||||
s.reset();
|
// s.reset();
|
||||||
for (auto& s : m_noTexZTestNoZWrite)
|
// for (auto& s : m_noTexZTestNoZWrite)
|
||||||
s.reset();
|
// s.reset();
|
||||||
for (auto& s : m_noTexNoZTestNoZWrite)
|
// for (auto& s : m_noTexNoZTestNoZWrite)
|
||||||
s.reset();
|
// s.reset();
|
||||||
for (auto& s : m_noTexAdditiveZTest)
|
// for (auto& s : m_noTexAdditiveZTest)
|
||||||
s.reset();
|
// s.reset();
|
||||||
for (auto& s : m_noTexAdditiveNoZTest)
|
// for (auto& s : m_noTexAdditiveNoZTest)
|
||||||
s.reset();
|
// s.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
CElementGenShaders::EShaderClass CElementGenShaders::GetShaderClass(CElementGen& gen) {
|
CElementGenShaders::EShaderClass CElementGenShaders::GetShaderClass(CElementGen& gen) {
|
||||||
|
@ -128,171 +128,171 @@ CElementGenShaders::EShaderClass CElementGenShaders::GetShaderClass(CElementGen&
|
||||||
return EShaderClass::NoTex;
|
return EShaderClass::NoTex;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CElementGenShaders::BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, CElementGen& gen) {
|
void CElementGenShaders::BuildShaderDataBinding(CElementGen& gen) {
|
||||||
CGenDescription* desc = gen.x1c_genDesc.GetObj();
|
CGenDescription* desc = gen.x1c_genDesc.GetObj();
|
||||||
std::array<boo::ObjToken<boo::IShaderPipeline>, 2>* regPipeline = nullptr;
|
// std::array<boo::ObjToken<boo::IShaderPipeline>, 2>* regPipeline = nullptr;
|
||||||
std::array<boo::ObjToken<boo::IShaderPipeline>, 2>* regPipelineSub = nullptr;
|
// std::array<boo::ObjToken<boo::IShaderPipeline>, 2>* regPipelineSub = nullptr;
|
||||||
std::array<boo::ObjToken<boo::IShaderPipeline>, 2>* redToAlphaPipeline = nullptr;
|
// std::array<boo::ObjToken<boo::IShaderPipeline>, 2>* redToAlphaPipeline = nullptr;
|
||||||
std::array<boo::ObjToken<boo::IShaderPipeline>, 2>* redToAlphaPipelineSub = nullptr;
|
// std::array<boo::ObjToken<boo::IShaderPipeline>, 2>* redToAlphaPipelineSub = nullptr;
|
||||||
std::array<boo::ObjToken<boo::IShaderPipeline>, 2>* regPipelinePmus = nullptr;
|
// std::array<boo::ObjToken<boo::IShaderPipeline>, 2>* regPipelinePmus = nullptr;
|
||||||
std::array<boo::ObjToken<boo::IShaderPipeline>, 2>* redToAlphaPipelinePmus = nullptr;
|
// std::array<boo::ObjToken<boo::IShaderPipeline>, 2>* redToAlphaPipelinePmus = nullptr;
|
||||||
|
//
|
||||||
if (gen.x26c_28_zTest) {
|
// if (gen.x26c_28_zTest) {
|
||||||
redToAlphaPipeline = &m_texRedToAlphaZTest;
|
// redToAlphaPipeline = &m_texRedToAlphaZTest;
|
||||||
regPipelineSub = &m_texZTestNoZWriteSub;
|
// regPipelineSub = &m_texZTestNoZWriteSub;
|
||||||
redToAlphaPipelineSub = &m_texRedToAlphaZTestSub;
|
// redToAlphaPipelineSub = &m_texRedToAlphaZTestSub;
|
||||||
} else {
|
// } else {
|
||||||
redToAlphaPipeline = &m_texRedToAlphaNoZTest;
|
// redToAlphaPipeline = &m_texRedToAlphaNoZTest;
|
||||||
regPipelineSub = &m_texNoZTestNoZWriteSub;
|
// regPipelineSub = &m_texNoZTestNoZWriteSub;
|
||||||
redToAlphaPipelineSub = &m_texRedToAlphaNoZTestSub;
|
// redToAlphaPipelineSub = &m_texRedToAlphaNoZTestSub;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (desc->x54_x40_TEXR) {
|
// if (desc->x54_x40_TEXR) {
|
||||||
if (desc->x58_x44_TIND) {
|
// if (desc->x58_x44_TIND) {
|
||||||
if (desc->x45_30_x32_24_CIND) {
|
// if (desc->x45_30_x32_24_CIND) {
|
||||||
if (gen.x26c_26_AAPH)
|
// if (gen.x26c_26_AAPH)
|
||||||
regPipeline = &m_cindTexAdditive;
|
// regPipeline = &m_cindTexAdditive;
|
||||||
else {
|
// else {
|
||||||
if (gen.x26c_27_ZBUF)
|
// if (gen.x26c_27_ZBUF)
|
||||||
regPipeline = &m_cindTexZWrite;
|
// regPipeline = &m_cindTexZWrite;
|
||||||
else
|
// else
|
||||||
regPipeline = &m_cindTexNoZWrite;
|
// regPipeline = &m_cindTexNoZWrite;
|
||||||
}
|
// }
|
||||||
} else {
|
// } else {
|
||||||
if (gen.x26c_26_AAPH)
|
// if (gen.x26c_26_AAPH)
|
||||||
regPipeline = &m_indTexAdditive;
|
// regPipeline = &m_indTexAdditive;
|
||||||
else {
|
// else {
|
||||||
if (gen.x26c_27_ZBUF)
|
// if (gen.x26c_27_ZBUF)
|
||||||
regPipeline = &m_indTexZWrite;
|
// regPipeline = &m_indTexZWrite;
|
||||||
else
|
// else
|
||||||
regPipeline = &m_indTexNoZWrite;
|
// regPipeline = &m_indTexNoZWrite;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
} else {
|
// } else {
|
||||||
if (gen.x26c_26_AAPH) {
|
// if (gen.x26c_26_AAPH) {
|
||||||
if (gen.x26c_28_zTest)
|
// if (gen.x26c_28_zTest)
|
||||||
regPipeline = &m_texAdditiveZTest;
|
// regPipeline = &m_texAdditiveZTest;
|
||||||
else
|
// else
|
||||||
regPipeline = &m_texAdditiveNoZTest;
|
// regPipeline = &m_texAdditiveNoZTest;
|
||||||
} else {
|
// } else {
|
||||||
if (gen.x26c_28_zTest) {
|
// if (gen.x26c_28_zTest) {
|
||||||
if (gen.x26c_27_ZBUF)
|
// if (gen.x26c_27_ZBUF)
|
||||||
regPipeline = &m_texZTestZWrite;
|
// regPipeline = &m_texZTestZWrite;
|
||||||
else
|
// else
|
||||||
regPipeline = &m_texZTestNoZWrite;
|
// regPipeline = &m_texZTestNoZWrite;
|
||||||
} else {
|
// } else {
|
||||||
if (gen.x26c_27_ZBUF)
|
// if (gen.x26c_27_ZBUF)
|
||||||
regPipeline = &m_texNoZTestZWrite;
|
// regPipeline = &m_texNoZTestZWrite;
|
||||||
else
|
// else
|
||||||
regPipeline = &m_texNoZTestNoZWrite;
|
// regPipeline = &m_texNoZTestNoZWrite;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
} else {
|
// } else {
|
||||||
if (gen.x26c_26_AAPH) {
|
// if (gen.x26c_26_AAPH) {
|
||||||
if (gen.x26c_28_zTest)
|
// if (gen.x26c_28_zTest)
|
||||||
regPipeline = &m_noTexAdditiveZTest;
|
// regPipeline = &m_noTexAdditiveZTest;
|
||||||
else
|
// else
|
||||||
regPipeline = &m_noTexAdditiveNoZTest;
|
// regPipeline = &m_noTexAdditiveNoZTest;
|
||||||
} else {
|
// } else {
|
||||||
if (gen.x26c_28_zTest) {
|
// if (gen.x26c_28_zTest) {
|
||||||
if (gen.x26c_27_ZBUF)
|
// if (gen.x26c_27_ZBUF)
|
||||||
regPipeline = &m_noTexZTestZWrite;
|
// regPipeline = &m_noTexZTestZWrite;
|
||||||
else
|
// else
|
||||||
regPipeline = &m_noTexZTestNoZWrite;
|
// regPipeline = &m_noTexZTestNoZWrite;
|
||||||
} else {
|
// } else {
|
||||||
if (gen.x26c_27_ZBUF)
|
// if (gen.x26c_27_ZBUF)
|
||||||
regPipeline = &m_noTexNoZTestZWrite;
|
// regPipeline = &m_noTexNoZTestZWrite;
|
||||||
else
|
// else
|
||||||
regPipeline = &m_noTexNoZTestNoZWrite;
|
// regPipeline = &m_noTexNoZTestNoZWrite;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (desc->x45_24_x31_26_PMUS) {
|
// if (desc->x45_24_x31_26_PMUS) {
|
||||||
if (desc->x54_x40_TEXR) {
|
// if (desc->x54_x40_TEXR) {
|
||||||
redToAlphaPipelinePmus = &m_texRedToAlphaZTest;
|
// redToAlphaPipelinePmus = &m_texRedToAlphaZTest;
|
||||||
if (desc->x44_31_x31_25_PMAB)
|
// if (desc->x44_31_x31_25_PMAB)
|
||||||
regPipelinePmus = &m_texAdditiveZTest;
|
// regPipelinePmus = &m_texAdditiveZTest;
|
||||||
else
|
// else
|
||||||
regPipelinePmus = &m_texZTestZWrite;
|
// regPipelinePmus = &m_texZTestZWrite;
|
||||||
} else {
|
// } else {
|
||||||
if (desc->x44_31_x31_25_PMAB)
|
// if (desc->x44_31_x31_25_PMAB)
|
||||||
regPipelinePmus = &m_noTexAdditiveZTest;
|
// regPipelinePmus = &m_noTexAdditiveZTest;
|
||||||
else
|
// else
|
||||||
regPipelinePmus = &m_noTexZTestZWrite;
|
// regPipelinePmus = &m_noTexZTestZWrite;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
const CUVElement* const texr = desc->x54_x40_TEXR.get();
|
// const CUVElement* const texr = desc->x54_x40_TEXR.get();
|
||||||
const CUVElement* const tind = desc->x58_x44_TIND.get();
|
// const CUVElement* const tind = desc->x58_x44_TIND.get();
|
||||||
int texCount = 0;
|
// int texCount = 0;
|
||||||
std::array<boo::ObjToken<boo::ITexture>, 3> textures;
|
// std::array<boo::ObjToken<boo::ITexture>, 3> textures;
|
||||||
|
//
|
||||||
if (texr) {
|
// if (texr) {
|
||||||
textures[0] = texr->GetValueTexture(0).GetObj()->GetBooTexture();
|
// textures[0] = texr->GetValueTexture(0).GetObj()->GetBooTexture();
|
||||||
texCount = 1;
|
// texCount = 1;
|
||||||
if (gen.m_instBuf) {
|
// if (gen.m_instBuf) {
|
||||||
if (tind) {
|
// if (tind) {
|
||||||
textures[1] = CGraphics::g_SpareTexture.get();
|
// textures[1] = CGraphics::g_SpareTexture.get();
|
||||||
textures[2] = tind->GetValueTexture(0).GetObj()->GetBooTexture();
|
// textures[2] = tind->GetValueTexture(0).GetObj()->GetBooTexture();
|
||||||
texCount = 3;
|
// texCount = 3;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (gen.m_instBuf) {
|
// if (gen.m_instBuf) {
|
||||||
const std::array<boo::ObjToken<boo::IGraphicsBuffer>, 1> uniforms{gen.m_uniformBuf.get()};
|
// const std::array<boo::ObjToken<boo::IGraphicsBuffer>, 1> uniforms{gen.m_uniformBuf.get()};
|
||||||
|
//
|
||||||
if (regPipeline != nullptr) {
|
// if (regPipeline != nullptr) {
|
||||||
for (size_t i = 0; i < gen.m_normalDataBind.size(); ++i) {
|
// for (size_t i = 0; i < gen.m_normalDataBind.size(); ++i) {
|
||||||
gen.m_normalDataBind[i] =
|
// gen.m_normalDataBind[i] =
|
||||||
ctx.newShaderDataBinding((*regPipeline)[i], nullptr, gen.m_instBuf.get(), nullptr, uniforms.size(),
|
// ctx.newShaderDataBinding((*regPipeline)[i], nullptr, gen.m_instBuf.get(), nullptr, uniforms.size(),
|
||||||
uniforms.data(), nullptr, texCount, textures.data(), nullptr, nullptr);
|
// uniforms.data(), nullptr, texCount, textures.data(), nullptr, nullptr);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
if (regPipelineSub != nullptr) {
|
// if (regPipelineSub != nullptr) {
|
||||||
for (size_t i = 0; i < gen.m_normalSubDataBind.size(); ++i) {
|
// for (size_t i = 0; i < gen.m_normalSubDataBind.size(); ++i) {
|
||||||
gen.m_normalSubDataBind[i] =
|
// gen.m_normalSubDataBind[i] =
|
||||||
ctx.newShaderDataBinding((*regPipelineSub)[i], nullptr, gen.m_instBuf.get(), nullptr, uniforms.size(),
|
// ctx.newShaderDataBinding((*regPipelineSub)[i], nullptr, gen.m_instBuf.get(), nullptr, uniforms.size(),
|
||||||
uniforms.data(), nullptr, texCount, textures.data(), nullptr, nullptr);
|
// uniforms.data(), nullptr, texCount, textures.data(), nullptr, nullptr);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
if (redToAlphaPipeline != nullptr) {
|
// if (redToAlphaPipeline != nullptr) {
|
||||||
for (size_t i = 0; i < gen.m_redToAlphaDataBind.size(); ++i) {
|
// for (size_t i = 0; i < gen.m_redToAlphaDataBind.size(); ++i) {
|
||||||
gen.m_redToAlphaDataBind[i] =
|
// gen.m_redToAlphaDataBind[i] =
|
||||||
ctx.newShaderDataBinding((*redToAlphaPipeline)[i], nullptr, gen.m_instBuf.get(), nullptr, uniforms.size(),
|
// ctx.newShaderDataBinding((*redToAlphaPipeline)[i], nullptr, gen.m_instBuf.get(), nullptr, uniforms.size(),
|
||||||
uniforms.data(), nullptr, texCount, textures.data(), nullptr, nullptr);
|
// uniforms.data(), nullptr, texCount, textures.data(), nullptr, nullptr);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
if (redToAlphaPipelineSub != nullptr) {
|
// if (redToAlphaPipelineSub != nullptr) {
|
||||||
for (size_t i = 0; i < gen.m_redToAlphaSubDataBind.size(); ++i) {
|
// for (size_t i = 0; i < gen.m_redToAlphaSubDataBind.size(); ++i) {
|
||||||
gen.m_redToAlphaSubDataBind[i] = ctx.newShaderDataBinding(
|
// gen.m_redToAlphaSubDataBind[i] = ctx.newShaderDataBinding(
|
||||||
(*redToAlphaPipelineSub)[i], nullptr, gen.m_instBuf.get(), nullptr, uniforms.size(), uniforms.data(),
|
// (*redToAlphaPipelineSub)[i], nullptr, gen.m_instBuf.get(), nullptr, uniforms.size(), uniforms.data(),
|
||||||
nullptr, texCount, textures.data(), nullptr, nullptr);
|
// nullptr, texCount, textures.data(), nullptr, nullptr);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (gen.m_instBufPmus) {
|
// if (gen.m_instBufPmus) {
|
||||||
const std::array<boo::ObjToken<boo::IGraphicsBuffer>, 1> uniforms{gen.m_uniformBufPmus.get()};
|
// const std::array<boo::ObjToken<boo::IGraphicsBuffer>, 1> uniforms{gen.m_uniformBufPmus.get()};
|
||||||
texCount = std::min(texCount, 1);
|
// texCount = std::min(texCount, 1);
|
||||||
|
//
|
||||||
if (regPipelinePmus != nullptr) {
|
// if (regPipelinePmus != nullptr) {
|
||||||
for (size_t i = 0; i < gen.m_normalDataBindPmus.size(); ++i) {
|
// for (size_t i = 0; i < gen.m_normalDataBindPmus.size(); ++i) {
|
||||||
gen.m_normalDataBindPmus[i] =
|
// gen.m_normalDataBindPmus[i] =
|
||||||
ctx.newShaderDataBinding((*regPipelinePmus)[i], nullptr, gen.m_instBufPmus.get(), nullptr, uniforms.size(),
|
// ctx.newShaderDataBinding((*regPipelinePmus)[i], nullptr, gen.m_instBufPmus.get(), nullptr, uniforms.size(),
|
||||||
uniforms.data(), nullptr, texCount, textures.data(), nullptr, nullptr);
|
// uniforms.data(), nullptr, texCount, textures.data(), nullptr, nullptr);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
if (redToAlphaPipelinePmus != nullptr) {
|
// if (redToAlphaPipelinePmus != nullptr) {
|
||||||
for (size_t i = 0; i < gen.m_redToAlphaDataBindPmus.size(); ++i) {
|
// for (size_t i = 0; i < gen.m_redToAlphaDataBindPmus.size(); ++i) {
|
||||||
gen.m_redToAlphaDataBindPmus[i] = ctx.newShaderDataBinding(
|
// gen.m_redToAlphaDataBindPmus[i] = ctx.newShaderDataBinding(
|
||||||
(*redToAlphaPipelinePmus)[i], nullptr, gen.m_instBufPmus.get(), nullptr, uniforms.size(), uniforms.data(),
|
// (*redToAlphaPipelinePmus)[i], nullptr, gen.m_instBufPmus.get(), nullptr, uniforms.size(), uniforms.data(),
|
||||||
nullptr, texCount, textures.data(), nullptr, nullptr);
|
// nullptr, texCount, textures.data(), nullptr, nullptr);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace metaforce
|
} // namespace metaforce
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
//#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
||||||
|
|
||||||
namespace metaforce {
|
namespace metaforce {
|
||||||
class CElementGen;
|
class CElementGen;
|
||||||
|
@ -12,39 +12,39 @@ public:
|
||||||
enum class EShaderClass { Tex, IndTex, NoTex };
|
enum class EShaderClass { Tex, IndTex, NoTex };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static inline std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texZTestZWrite;
|
// static inline std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texZTestZWrite;
|
||||||
static inline std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texNoZTestZWrite;
|
// static inline std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texNoZTestZWrite;
|
||||||
static inline std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texZTestNoZWrite;
|
// static inline std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texZTestNoZWrite;
|
||||||
static inline std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texNoZTestNoZWrite;
|
// static inline std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texNoZTestNoZWrite;
|
||||||
static inline std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texAdditiveZTest;
|
// static inline std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texAdditiveZTest;
|
||||||
static inline std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texAdditiveNoZTest;
|
// static inline std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texAdditiveNoZTest;
|
||||||
static inline std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texRedToAlphaZTest;
|
// static inline std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texRedToAlphaZTest;
|
||||||
static inline std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texRedToAlphaNoZTest;
|
// static inline std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texRedToAlphaNoZTest;
|
||||||
static inline std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texZTestNoZWriteSub;
|
// static inline std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texZTestNoZWriteSub;
|
||||||
static inline std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texNoZTestNoZWriteSub;
|
// static inline std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texNoZTestNoZWriteSub;
|
||||||
static inline std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texRedToAlphaZTestSub;
|
// static inline std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texRedToAlphaZTestSub;
|
||||||
static inline std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texRedToAlphaNoZTestSub;
|
// static inline std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texRedToAlphaNoZTestSub;
|
||||||
|
//
|
||||||
static inline std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_indTexZWrite;
|
// static inline std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_indTexZWrite;
|
||||||
static inline std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_indTexNoZWrite;
|
// static inline std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_indTexNoZWrite;
|
||||||
static inline std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_indTexAdditive;
|
// static inline std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_indTexAdditive;
|
||||||
|
//
|
||||||
static inline std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_cindTexZWrite;
|
// static inline std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_cindTexZWrite;
|
||||||
static inline std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_cindTexNoZWrite;
|
// static inline std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_cindTexNoZWrite;
|
||||||
static inline std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_cindTexAdditive;
|
// static inline std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_cindTexAdditive;
|
||||||
|
//
|
||||||
static inline std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_noTexZTestZWrite;
|
// static inline std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_noTexZTestZWrite;
|
||||||
static inline std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_noTexNoZTestZWrite;
|
// static inline std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_noTexNoZTestZWrite;
|
||||||
static inline std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_noTexZTestNoZWrite;
|
// static inline std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_noTexZTestNoZWrite;
|
||||||
static inline std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_noTexNoZTestNoZWrite;
|
// static inline std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_noTexNoZTestNoZWrite;
|
||||||
static inline std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_noTexAdditiveZTest;
|
// static inline std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_noTexAdditiveZTest;
|
||||||
static inline std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_noTexAdditiveNoZTest;
|
// static inline std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_noTexAdditiveNoZTest;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void Initialize();
|
static void Initialize();
|
||||||
static void Shutdown();
|
static void Shutdown();
|
||||||
static EShaderClass GetShaderClass(CElementGen& gen);
|
static EShaderClass GetShaderClass(CElementGen& gen);
|
||||||
static void BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, CElementGen& gen);
|
static void BuildShaderDataBinding(CElementGen& gen);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace metaforce
|
} // namespace metaforce
|
||||||
|
|
|
@ -5,15 +5,19 @@
|
||||||
#include "Runtime/Graphics/CGraphics.hpp"
|
#include "Runtime/Graphics/CGraphics.hpp"
|
||||||
#include "Runtime/Graphics/CTexture.hpp"
|
#include "Runtime/Graphics/CTexture.hpp"
|
||||||
|
|
||||||
#include <hecl/Pipeline.hpp>
|
//#include <hecl/Pipeline.hpp>
|
||||||
|
|
||||||
namespace metaforce {
|
namespace metaforce {
|
||||||
|
|
||||||
static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
|
//static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
|
||||||
|
|
||||||
void CEnergyBarShader::Initialize() { s_Pipeline = hecl::conv->convert(Shader_CEnergyBarShader{}); }
|
void CEnergyBarShader::Initialize() {
|
||||||
|
// s_Pipeline = hecl::conv->convert(Shader_CEnergyBarShader{});
|
||||||
|
}
|
||||||
|
|
||||||
void CEnergyBarShader::Shutdown() { s_Pipeline.reset(); }
|
void CEnergyBarShader::Shutdown() {
|
||||||
|
// s_Pipeline.reset();
|
||||||
|
}
|
||||||
|
|
||||||
void CEnergyBarShader::updateModelMatrix() {
|
void CEnergyBarShader::updateModelMatrix() {
|
||||||
m_uniform.m_matrix = CGraphics::GetPerspectiveProjectionMatrix(true) * CGraphics::g_GXModelView.toMatrix4f();
|
m_uniform.m_matrix = CGraphics::GetPerspectiveProjectionMatrix(true) * CGraphics::g_GXModelView.toMatrix4f();
|
||||||
|
@ -31,60 +35,60 @@ void CEnergyBarShader::draw(const zeus::CColor& color0, const std::vector<Vertex
|
||||||
if (totalVerts > m_maxVerts) {
|
if (totalVerts > m_maxVerts) {
|
||||||
m_maxVerts = totalVerts;
|
m_maxVerts = totalVerts;
|
||||||
m_tex = tex;
|
m_tex = tex;
|
||||||
CGraphics::CommitResources([this](boo::IGraphicsDataFactory::Context& ctx) {
|
// CGraphics::CommitResources([this](boo::IGraphicsDataFactory::Context& ctx) {
|
||||||
m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(Vertex), m_maxVerts);
|
// m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(Vertex), m_maxVerts);
|
||||||
|
//
|
||||||
std::array<boo::ObjToken<boo::IGraphicsBuffer>, 1> bufs;
|
// std::array<boo::ObjToken<boo::IGraphicsBuffer>, 1> bufs;
|
||||||
constexpr std::array<boo::PipelineStage, 1> stages{boo::PipelineStage::Vertex};
|
// constexpr std::array<boo::PipelineStage, 1> stages{boo::PipelineStage::Vertex};
|
||||||
const std::array<boo::ObjToken<boo::ITexture>, 1> texs{m_tex->GetBooTexture()};
|
// const std::array<boo::ObjToken<boo::ITexture>, 1> texs{m_tex->GetBooTexture()};
|
||||||
|
//
|
||||||
for (size_t i = 0; i < m_uniBuf.size(); ++i) {
|
// for (size_t i = 0; i < m_uniBuf.size(); ++i) {
|
||||||
m_uniBuf[i] = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
|
// m_uniBuf[i] = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
|
||||||
bufs[0] = m_uniBuf[i].get();
|
// bufs[0] = m_uniBuf[i].get();
|
||||||
m_dataBind[i] =
|
// m_dataBind[i] =
|
||||||
ctx.newShaderDataBinding(s_Pipeline, m_vbo.get(), nullptr, nullptr, bufs.size(), bufs.data(), stages.data(),
|
// ctx.newShaderDataBinding(s_Pipeline, m_vbo.get(), nullptr, nullptr, bufs.size(), bufs.data(), stages.data(),
|
||||||
nullptr, nullptr, texs.size(), texs.data(), nullptr, nullptr);
|
// nullptr, nullptr, texs.size(), texs.data(), nullptr, nullptr);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
return true;
|
// return true;
|
||||||
} BooTrace);
|
// } BooTrace);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t vertIter = 0;
|
size_t vertIter = 0;
|
||||||
Vertex* verts = reinterpret_cast<Vertex*>(m_vbo->map(sizeof(Vertex) * totalVerts));
|
// Vertex* verts = reinterpret_cast<Vertex*>(m_vbo->map(sizeof(Vertex) * totalVerts));
|
||||||
if (verts0.size()) {
|
// if (verts0.size()) {
|
||||||
memmove(verts, verts0.data(), sizeof(Vertex) * verts0.size());
|
// memmove(verts, verts0.data(), sizeof(Vertex) * verts0.size());
|
||||||
vertIter += verts0.size();
|
// vertIter += verts0.size();
|
||||||
}
|
// }
|
||||||
if (verts1.size()) {
|
// if (verts1.size()) {
|
||||||
memmove(verts + vertIter, verts1.data(), sizeof(Vertex) * verts1.size());
|
// memmove(verts + vertIter, verts1.data(), sizeof(Vertex) * verts1.size());
|
||||||
vertIter += verts1.size();
|
// vertIter += verts1.size();
|
||||||
}
|
// }
|
||||||
if (verts2.size()) {
|
// if (verts2.size()) {
|
||||||
memmove(verts + vertIter, verts2.data(), sizeof(Vertex) * verts2.size());
|
// memmove(verts + vertIter, verts2.data(), sizeof(Vertex) * verts2.size());
|
||||||
}
|
// }
|
||||||
m_vbo->unmap();
|
// m_vbo->unmap();
|
||||||
|
|
||||||
vertIter = 0;
|
vertIter = 0;
|
||||||
if (verts0.size()) {
|
if (verts0.size()) {
|
||||||
m_uniform.m_color = color0;
|
m_uniform.m_color = color0;
|
||||||
m_uniBuf[0]->load(&m_uniform, sizeof(Uniform));
|
// m_uniBuf[0]->load(&m_uniform, sizeof(Uniform));
|
||||||
CGraphics::SetShaderDataBinding(m_dataBind[0]);
|
// CGraphics::SetShaderDataBinding(m_dataBind[0]);
|
||||||
CGraphics::DrawArray(0, verts0.size());
|
// CGraphics::DrawArray(0, verts0.size());
|
||||||
vertIter += verts0.size();
|
vertIter += verts0.size();
|
||||||
}
|
}
|
||||||
if (verts1.size()) {
|
if (verts1.size()) {
|
||||||
m_uniform.m_color = color1;
|
m_uniform.m_color = color1;
|
||||||
m_uniBuf[1]->load(&m_uniform, sizeof(Uniform));
|
// m_uniBuf[1]->load(&m_uniform, sizeof(Uniform));
|
||||||
CGraphics::SetShaderDataBinding(m_dataBind[1]);
|
// CGraphics::SetShaderDataBinding(m_dataBind[1]);
|
||||||
CGraphics::DrawArray(vertIter, verts1.size());
|
// CGraphics::DrawArray(vertIter, verts1.size());
|
||||||
vertIter += verts1.size();
|
vertIter += verts1.size();
|
||||||
}
|
}
|
||||||
if (verts2.size()) {
|
if (verts2.size()) {
|
||||||
m_uniform.m_color = color2;
|
m_uniform.m_color = color2;
|
||||||
m_uniBuf[2]->load(&m_uniform, sizeof(Uniform));
|
// m_uniBuf[2]->load(&m_uniform, sizeof(Uniform));
|
||||||
CGraphics::SetShaderDataBinding(m_dataBind[2]);
|
// CGraphics::SetShaderDataBinding(m_dataBind[2]);
|
||||||
CGraphics::DrawArray(vertIter, verts2.size());
|
// CGraphics::DrawArray(vertIter, verts2.size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
//#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
||||||
|
|
||||||
#include <zeus/CColor.hpp>
|
#include <zeus/CColor.hpp>
|
||||||
#include <zeus/CMatrix4f.hpp>
|
#include <zeus/CMatrix4f.hpp>
|
||||||
|
@ -25,9 +25,9 @@ private:
|
||||||
zeus::CMatrix4f m_matrix;
|
zeus::CMatrix4f m_matrix;
|
||||||
zeus::CColor m_color;
|
zeus::CColor m_color;
|
||||||
};
|
};
|
||||||
boo::ObjToken<boo::IGraphicsBufferD> m_vbo;
|
// boo::ObjToken<boo::IGraphicsBufferD> m_vbo;
|
||||||
std::array<boo::ObjToken<boo::IGraphicsBufferD>, 3> m_uniBuf;
|
// std::array<boo::ObjToken<boo::IGraphicsBufferD>, 3> m_uniBuf;
|
||||||
std::array<boo::ObjToken<boo::IShaderDataBinding>, 3> m_dataBind;
|
// std::array<boo::ObjToken<boo::IShaderDataBinding>, 3> m_dataBind;
|
||||||
Uniform m_uniform;
|
Uniform m_uniform;
|
||||||
const CTexture* m_tex = nullptr;
|
const CTexture* m_tex = nullptr;
|
||||||
size_t m_maxVerts = 0;
|
size_t m_maxVerts = 0;
|
||||||
|
|
|
@ -2,56 +2,56 @@
|
||||||
|
|
||||||
#include "Runtime/World/CEnvFxManager.hpp"
|
#include "Runtime/World/CEnvFxManager.hpp"
|
||||||
|
|
||||||
#include <hecl/Pipeline.hpp>
|
//#include <hecl/Pipeline.hpp>
|
||||||
|
|
||||||
namespace metaforce {
|
namespace metaforce {
|
||||||
boo::ObjToken<boo::IShaderPipeline> CEnvFxShaders::m_snowPipeline;
|
//boo::ObjToken<boo::IShaderPipeline> CEnvFxShaders::m_snowPipeline;
|
||||||
boo::ObjToken<boo::IShaderPipeline> CEnvFxShaders::m_underwaterPipeline;
|
//boo::ObjToken<boo::IShaderPipeline> CEnvFxShaders::m_underwaterPipeline;
|
||||||
|
|
||||||
void CEnvFxShaders::Initialize() {
|
void CEnvFxShaders::Initialize() {
|
||||||
m_snowPipeline = hecl::conv->convert(Shader_CEnvFxSnowShader{});
|
// m_snowPipeline = hecl::conv->convert(Shader_CEnvFxSnowShader{});
|
||||||
m_underwaterPipeline = hecl::conv->convert(Shader_CEnvFxUnderwaterShader{});
|
// m_underwaterPipeline = hecl::conv->convert(Shader_CEnvFxUnderwaterShader{});
|
||||||
}
|
}
|
||||||
|
|
||||||
void CEnvFxShaders::Shutdown() {
|
void CEnvFxShaders::Shutdown() {
|
||||||
m_snowPipeline.reset();
|
// m_snowPipeline.reset();
|
||||||
m_underwaterPipeline.reset();
|
// m_underwaterPipeline.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CEnvFxShaders::BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, CEnvFxManager& fxMgr,
|
void CEnvFxShaders::BuildShaderDataBinding(CEnvFxManager& fxMgr,
|
||||||
CEnvFxManagerGrid& grid) {
|
CEnvFxManagerGrid& grid) {
|
||||||
const auto uBufInfo = grid.m_uniformBuf.getBufferInfo();
|
// const auto uBufInfo = grid.m_uniformBuf.getBufferInfo();
|
||||||
const auto iBufInfo = grid.m_instBuf.getBufferInfo();
|
// const auto iBufInfo = grid.m_instBuf.getBufferInfo();
|
||||||
|
|
||||||
const std::array<boo::ObjToken<boo::IGraphicsBuffer>, 2> uniforms{{
|
// const std::array<boo::ObjToken<boo::IGraphicsBuffer>, 2> uniforms{{
|
||||||
uBufInfo.first.get(),
|
// uBufInfo.first.get(),
|
||||||
fxMgr.m_fogUniformBuf.get(),
|
// fxMgr.m_fogUniformBuf.get(),
|
||||||
}};
|
// }};
|
||||||
const std::array<size_t, 2> ubufOffsets{
|
// const std::array<size_t, 2> ubufOffsets{
|
||||||
size_t(uBufInfo.second),
|
// size_t(uBufInfo.second),
|
||||||
0,
|
// 0,
|
||||||
};
|
// };
|
||||||
constexpr std::array<size_t, 2> ubufSizes{
|
// constexpr std::array<size_t, 2> ubufSizes{
|
||||||
sizeof(CEnvFxShaders::Uniform),
|
// sizeof(CEnvFxShaders::Uniform),
|
||||||
sizeof(CGraphics::g_Fog),
|
// sizeof(CGraphics::g_Fog),
|
||||||
};
|
// };
|
||||||
constexpr std::array<boo::PipelineStage, 2> uniformStages{
|
// constexpr std::array<boo::PipelineStage, 2> uniformStages{
|
||||||
boo::PipelineStage::Vertex,
|
// boo::PipelineStage::Vertex,
|
||||||
boo::PipelineStage::Fragment,
|
// boo::PipelineStage::Fragment,
|
||||||
};
|
// };
|
||||||
std::array<boo::ObjToken<boo::ITexture>, 2> textures{
|
// std::array<boo::ObjToken<boo::ITexture>, 2> textures{
|
||||||
fxMgr.xb74_txtrSnowFlake->GetBooTexture(),
|
// fxMgr.xb74_txtrSnowFlake->GetBooTexture(),
|
||||||
fxMgr.x40_txtrEnvGradient->GetBooTexture(),
|
// fxMgr.x40_txtrEnvGradient->GetBooTexture(),
|
||||||
};
|
// };
|
||||||
|
//
|
||||||
grid.m_snowBinding = ctx.newShaderDataBinding(
|
// grid.m_snowBinding = ctx.newShaderDataBinding(
|
||||||
m_snowPipeline, nullptr, iBufInfo.first.get(), nullptr, uniforms.size(), uniforms.data(), uniformStages.data(),
|
// m_snowPipeline, nullptr, iBufInfo.first.get(), nullptr, uniforms.size(), uniforms.data(), uniformStages.data(),
|
||||||
ubufOffsets.data(), ubufSizes.data(), textures.size(), textures.data(), nullptr, nullptr, 0, iBufInfo.second);
|
// ubufOffsets.data(), ubufSizes.data(), textures.size(), textures.data(), nullptr, nullptr, 0, iBufInfo.second);
|
||||||
textures[0] = fxMgr.xc48_underwaterFlake->GetBooTexture();
|
// textures[0] = fxMgr.xc48_underwaterFlake->GetBooTexture();
|
||||||
grid.m_underwaterBinding =
|
// grid.m_underwaterBinding =
|
||||||
ctx.newShaderDataBinding(m_underwaterPipeline, nullptr, iBufInfo.first.get(), nullptr, uniforms.size(),
|
// ctx.newShaderDataBinding(m_underwaterPipeline, nullptr, iBufInfo.first.get(), nullptr, uniforms.size(),
|
||||||
uniforms.data(), uniformStages.data(), ubufOffsets.data(), ubufSizes.data(),
|
// uniforms.data(), uniformStages.data(), ubufOffsets.data(), ubufSizes.data(),
|
||||||
textures.size(), textures.data(), nullptr, nullptr, 0, iBufInfo.second);
|
// textures.size(), textures.data(), nullptr, nullptr, 0, iBufInfo.second);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace metaforce
|
} // namespace metaforce
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
//#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
||||||
|
|
||||||
#include <zeus/CColor.hpp>
|
#include <zeus/CColor.hpp>
|
||||||
#include <zeus/CMatrix4f.hpp>
|
#include <zeus/CMatrix4f.hpp>
|
||||||
|
@ -28,13 +28,13 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static boo::ObjToken<boo::IShaderPipeline> m_snowPipeline;
|
// static boo::ObjToken<boo::IShaderPipeline> m_snowPipeline;
|
||||||
static boo::ObjToken<boo::IShaderPipeline> m_underwaterPipeline;
|
// static boo::ObjToken<boo::IShaderPipeline> m_underwaterPipeline;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void Initialize();
|
static void Initialize();
|
||||||
static void Shutdown();
|
static void Shutdown();
|
||||||
static void BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, CEnvFxManager& fxMgr,
|
static void BuildShaderDataBinding(CEnvFxManager& fxMgr,
|
||||||
CEnvFxManagerGrid& grid);
|
CEnvFxManagerGrid& grid);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -3,200 +3,202 @@
|
||||||
#include "Runtime/World/CRipple.hpp"
|
#include "Runtime/World/CRipple.hpp"
|
||||||
#include "Runtime/World/CRippleManager.hpp"
|
#include "Runtime/World/CRippleManager.hpp"
|
||||||
|
|
||||||
#include <hecl/Pipeline.hpp>
|
//#include <hecl/Pipeline.hpp>
|
||||||
|
|
||||||
namespace metaforce {
|
namespace metaforce {
|
||||||
|
|
||||||
CFluidPlaneShader::Cache CFluidPlaneShader::_cache = {};
|
//CFluidPlaneShader::Cache CFluidPlaneShader::_cache = {};
|
||||||
|
//
|
||||||
u16 CFluidPlaneShader::Cache::MakeCacheKey(const SFluidPlaneShaderInfo& info) {
|
//u16 CFluidPlaneShader::Cache::MakeCacheKey(const SFluidPlaneShaderInfo& info) {
|
||||||
u16 ret = 0;
|
// u16 ret = 0;
|
||||||
|
//
|
||||||
switch (info.m_type) {
|
// switch (info.m_type) {
|
||||||
case EFluidType::NormalWater:
|
// case EFluidType::NormalWater:
|
||||||
case EFluidType::PhazonFluid:
|
// case EFluidType::PhazonFluid:
|
||||||
case EFluidType::Four:
|
// case EFluidType::Four:
|
||||||
if (info.m_hasLightmap) {
|
// if (info.m_hasLightmap) {
|
||||||
ret |= 1 << 2;
|
// ret |= 1 << 2;
|
||||||
if (info.m_doubleLightmapBlend)
|
// if (info.m_doubleLightmapBlend)
|
||||||
ret |= 1 << 3;
|
// ret |= 1 << 3;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (!info.m_hasEnvMap && info.m_hasEnvBumpMap)
|
// if (!info.m_hasEnvMap && info.m_hasEnvBumpMap)
|
||||||
ret |= 1 << 4;
|
// ret |= 1 << 4;
|
||||||
|
//
|
||||||
if (info.m_hasEnvMap)
|
// if (info.m_hasEnvMap)
|
||||||
ret |= 1 << 5;
|
// ret |= 1 << 5;
|
||||||
|
//
|
||||||
break;
|
// break;
|
||||||
|
//
|
||||||
case EFluidType::PoisonWater:
|
// case EFluidType::PoisonWater:
|
||||||
ret |= 1;
|
// ret |= 1;
|
||||||
|
//
|
||||||
if (info.m_hasLightmap) {
|
// if (info.m_hasLightmap) {
|
||||||
ret |= 1 << 2;
|
// ret |= 1 << 2;
|
||||||
if (info.m_doubleLightmapBlend)
|
// if (info.m_doubleLightmapBlend)
|
||||||
ret |= 1 << 3;
|
// ret |= 1 << 3;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (info.m_hasEnvBumpMap)
|
// if (info.m_hasEnvBumpMap)
|
||||||
ret |= 1 << 4;
|
// ret |= 1 << 4;
|
||||||
|
//
|
||||||
break;
|
// break;
|
||||||
|
//
|
||||||
case EFluidType::Lava:
|
// case EFluidType::Lava:
|
||||||
ret |= 2;
|
// ret |= 2;
|
||||||
|
//
|
||||||
if (info.m_hasBumpMap)
|
// if (info.m_hasBumpMap)
|
||||||
ret |= 1 << 2;
|
// ret |= 1 << 2;
|
||||||
|
//
|
||||||
break;
|
// break;
|
||||||
|
//
|
||||||
case EFluidType::ThickLava:
|
// case EFluidType::ThickLava:
|
||||||
ret |= 3;
|
// ret |= 3;
|
||||||
|
//
|
||||||
if (info.m_hasBumpMap)
|
// if (info.m_hasBumpMap)
|
||||||
ret |= 1 << 2;
|
// ret |= 1 << 2;
|
||||||
|
//
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (info.m_hasPatternTex1)
|
// if (info.m_hasPatternTex1)
|
||||||
ret |= 1 << 6;
|
// ret |= 1 << 6;
|
||||||
if (info.m_hasPatternTex2)
|
// if (info.m_hasPatternTex2)
|
||||||
ret |= 1 << 7;
|
// ret |= 1 << 7;
|
||||||
if (info.m_hasColorTex)
|
// if (info.m_hasColorTex)
|
||||||
ret |= 1 << 8;
|
// ret |= 1 << 8;
|
||||||
|
//
|
||||||
if (info.m_additive)
|
// if (info.m_additive)
|
||||||
ret |= 1 << 9;
|
// ret |= 1 << 9;
|
||||||
|
//
|
||||||
return ret;
|
// return ret;
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
u16 CFluidPlaneShader::Cache::MakeCacheKey(const SFluidPlaneDoorShaderInfo& info) {
|
//u16 CFluidPlaneShader::Cache::MakeCacheKey(const SFluidPlaneDoorShaderInfo& info) {
|
||||||
u16 ret = 0;
|
// u16 ret = 0;
|
||||||
|
//
|
||||||
if (info.m_hasPatternTex1)
|
// if (info.m_hasPatternTex1)
|
||||||
ret |= 1 << 0;
|
// ret |= 1 << 0;
|
||||||
if (info.m_hasPatternTex2)
|
// if (info.m_hasPatternTex2)
|
||||||
ret |= 1 << 1;
|
// ret |= 1 << 1;
|
||||||
if (info.m_hasColorTex)
|
// if (info.m_hasColorTex)
|
||||||
ret |= 1 << 2;
|
// ret |= 1 << 2;
|
||||||
|
//
|
||||||
return ret;
|
// return ret;
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
template <>
|
//template <>
|
||||||
CFluidPlaneShader::ShaderPair
|
//CFluidPlaneShader::ShaderPair
|
||||||
CFluidPlaneShader::Cache::GetOrBuildShader<SFluidPlaneShaderInfo>(const SFluidPlaneShaderInfo& info) {
|
//CFluidPlaneShader::Cache::GetOrBuildShader<SFluidPlaneShaderInfo>(const SFluidPlaneShaderInfo& info) {
|
||||||
OPTICK_EVENT();
|
// OPTICK_EVENT();
|
||||||
u16 key = MakeCacheKey(info);
|
// u16 key = MakeCacheKey(info);
|
||||||
auto& slot = CacheSlot(info, key);
|
// auto& slot = CacheSlot(info, key);
|
||||||
if (slot.m_regular)
|
// if (slot.m_regular)
|
||||||
return slot;
|
// return slot;
|
||||||
|
//
|
||||||
slot.m_regular = hecl::conv->convert(Shader_CFluidPlaneShader{info, false});
|
// slot.m_regular = hecl::conv->convert(Shader_CFluidPlaneShader{info, false});
|
||||||
if (info.m_tessellation)
|
// if (info.m_tessellation)
|
||||||
slot.m_tessellation = hecl::conv->convert(Shader_CFluidPlaneShader{info, true});
|
// slot.m_tessellation = hecl::conv->convert(Shader_CFluidPlaneShader{info, true});
|
||||||
|
//
|
||||||
return slot;
|
// return slot;
|
||||||
}
|
//}
|
||||||
template <>
|
//template <>
|
||||||
CFluidPlaneShader::ShaderPair
|
//CFluidPlaneShader::ShaderPair
|
||||||
CFluidPlaneShader::Cache::GetOrBuildShader<SFluidPlaneDoorShaderInfo>(const SFluidPlaneDoorShaderInfo& info) {
|
//CFluidPlaneShader::Cache::GetOrBuildShader<SFluidPlaneDoorShaderInfo>(const SFluidPlaneDoorShaderInfo& info) {
|
||||||
OPTICK_EVENT();
|
// OPTICK_EVENT();
|
||||||
u16 key = MakeCacheKey(info);
|
// u16 key = MakeCacheKey(info);
|
||||||
auto& slot = CacheSlot(info, key);
|
// auto& slot = CacheSlot(info, key);
|
||||||
if (slot.m_regular)
|
// if (slot.m_regular)
|
||||||
return slot;
|
// return slot;
|
||||||
|
//
|
||||||
slot.m_regular = hecl::conv->convert(Shader_CFluidPlaneDoorShader{info});
|
// slot.m_regular = hecl::conv->convert(Shader_CFluidPlaneDoorShader{info});
|
||||||
|
//
|
||||||
return slot;
|
// return slot;
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
void CFluidPlaneShader::Cache::Clear() {
|
//void CFluidPlaneShader::Cache::Clear() {
|
||||||
for (auto& p : m_cache)
|
// for (auto& p : m_cache)
|
||||||
p.reset();
|
// p.reset();
|
||||||
for (auto& p : m_doorCache)
|
// for (auto& p : m_doorCache)
|
||||||
p.reset();
|
// p.reset();
|
||||||
}
|
//}
|
||||||
|
|
||||||
void CFluidPlaneShader::PrepareBinding(u32 maxVertCount) {
|
void CFluidPlaneShader::PrepareBinding(u32 maxVertCount) {
|
||||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
// CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
||||||
m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(Vertex), maxVertCount);
|
// m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(Vertex), maxVertCount);
|
||||||
if (m_pipelines.m_tessellation) {
|
// if (m_pipelines.m_tessellation) {
|
||||||
m_pvbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(PatchVertex), maxVertCount);
|
// m_pvbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(PatchVertex), maxVertCount);
|
||||||
}
|
// }
|
||||||
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
|
// m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
|
||||||
|
//
|
||||||
const std::array<boo::ObjToken<boo::IGraphicsBuffer>, 3> ubufs{{
|
// const std::array<boo::ObjToken<boo::IGraphicsBuffer>, 3> ubufs{{
|
||||||
m_uniBuf.get(),
|
// m_uniBuf.get(),
|
||||||
m_uniBuf.get(),
|
// m_uniBuf.get(),
|
||||||
m_uniBuf.get(),
|
// m_uniBuf.get(),
|
||||||
}};
|
// }};
|
||||||
constexpr std::array<boo::PipelineStage, 3> ubufStages{
|
// constexpr std::array<boo::PipelineStage, 3> ubufStages{
|
||||||
boo::PipelineStage::Vertex,
|
// boo::PipelineStage::Vertex,
|
||||||
boo::PipelineStage::Vertex,
|
// boo::PipelineStage::Vertex,
|
||||||
boo::PipelineStage::Fragment,
|
// boo::PipelineStage::Fragment,
|
||||||
};
|
// };
|
||||||
constexpr std::array<size_t, 3> ubufOffs{
|
// constexpr std::array<size_t, 3> ubufOffs{
|
||||||
0,
|
// 0,
|
||||||
0,
|
// 0,
|
||||||
1280,
|
// 1280,
|
||||||
};
|
// };
|
||||||
constexpr std::array<size_t, 3> ubufSizes{
|
// constexpr std::array<size_t, 3> ubufSizes{
|
||||||
1280,
|
// 1280,
|
||||||
1280,
|
// 1280,
|
||||||
sizeof(CModelShaders::LightingUniform),
|
// sizeof(CModelShaders::LightingUniform),
|
||||||
};
|
// };
|
||||||
|
//
|
||||||
size_t texCount = 0;
|
// size_t texCount = 0;
|
||||||
std::array<boo::ObjToken<boo::ITexture>, 8> texs;
|
// std::array<boo::ObjToken<boo::ITexture>, 8> texs;
|
||||||
if (m_patternTex1) {
|
// if (m_patternTex1) {
|
||||||
texs[texCount++] = m_patternTex1->GetBooTexture();
|
// texs[texCount++] = m_patternTex1->GetBooTexture();
|
||||||
}
|
// }
|
||||||
if (m_patternTex2) {
|
// if (m_patternTex2) {
|
||||||
texs[texCount++] = m_patternTex2->GetBooTexture();
|
// texs[texCount++] = m_patternTex2->GetBooTexture();
|
||||||
}
|
// }
|
||||||
if (m_colorTex) {
|
// if (m_colorTex) {
|
||||||
texs[texCount++] = m_colorTex->GetBooTexture();
|
// texs[texCount++] = m_colorTex->GetBooTexture();
|
||||||
}
|
// }
|
||||||
if (m_bumpMap) {
|
// if (m_bumpMap) {
|
||||||
texs[texCount++] = m_bumpMap->GetBooTexture();
|
// texs[texCount++] = m_bumpMap->GetBooTexture();
|
||||||
}
|
// }
|
||||||
if (m_envMap) {
|
// if (m_envMap) {
|
||||||
texs[texCount++] = m_envMap->GetBooTexture();
|
// texs[texCount++] = m_envMap->GetBooTexture();
|
||||||
}
|
// }
|
||||||
if (m_envBumpMap) {
|
// if (m_envBumpMap) {
|
||||||
texs[texCount++] = m_envBumpMap->GetBooTexture();
|
// texs[texCount++] = m_envBumpMap->GetBooTexture();
|
||||||
}
|
// }
|
||||||
if (m_lightmap) {
|
// if (m_lightmap) {
|
||||||
texs[texCount++] = m_lightmap->GetBooTexture();
|
// texs[texCount++] = m_lightmap->GetBooTexture();
|
||||||
}
|
// }
|
||||||
auto regular = ctx.newShaderDataBinding(m_pipelines.m_regular, m_vbo.get(), nullptr, nullptr, ubufs.size(),
|
// auto regular = ctx.newShaderDataBinding(m_pipelines.m_regular, m_vbo.get(), nullptr, nullptr, ubufs.size(),
|
||||||
ubufs.data(), ubufStages.data(), ubufOffs.data(), ubufSizes.data(),
|
// ubufs.data(), ubufStages.data(), ubufOffs.data(), ubufSizes.data(),
|
||||||
texCount, texs.data(), nullptr, nullptr);
|
// texCount, texs.data(), nullptr, nullptr);
|
||||||
boo::ObjToken<boo::IShaderDataBinding> tessellation;
|
// boo::ObjToken<boo::IShaderDataBinding> tessellation;
|
||||||
if (m_pipelines.m_tessellation) {
|
// if (m_pipelines.m_tessellation) {
|
||||||
texs[texCount++] = m_rippleMap.get();
|
// texs[texCount++] = m_rippleMap.get();
|
||||||
tessellation = ctx.newShaderDataBinding(m_pipelines.m_tessellation, m_pvbo.get(), nullptr, nullptr, ubufs.size(),
|
// tessellation = ctx.newShaderDataBinding(m_pipelines.m_tessellation, m_pvbo.get(), nullptr, nullptr, ubufs.size(),
|
||||||
ubufs.data(), ubufStages.data(), ubufOffs.data(), ubufSizes.data(),
|
// ubufs.data(), ubufStages.data(), ubufOffs.data(), ubufSizes.data(),
|
||||||
texCount, texs.data(), nullptr, nullptr);
|
// texCount, texs.data(), nullptr, nullptr);
|
||||||
}
|
// }
|
||||||
m_dataBind = {regular, tessellation};
|
// m_dataBind = {regular, tessellation};
|
||||||
return true;
|
// return true;
|
||||||
} BooTrace);
|
// } BooTrace);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CFluidPlaneShader::Shutdown() { _cache.Clear(); }
|
void CFluidPlaneShader::Shutdown() {
|
||||||
|
// _cache.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
CFluidPlaneShader::CFluidPlaneShader(EFluidType type, const TLockedToken<CTexture>& patternTex1,
|
CFluidPlaneShader::CFluidPlaneShader(EFluidType type, const TLockedToken<CTexture>& patternTex1,
|
||||||
const TLockedToken<CTexture>& patternTex2, const TLockedToken<CTexture>& colorTex,
|
const TLockedToken<CTexture>& patternTex2, const TLockedToken<CTexture>& colorTex,
|
||||||
const TLockedToken<CTexture>& bumpMap, const TLockedToken<CTexture>& envMap,
|
const TLockedToken<CTexture>& bumpMap, const TLockedToken<CTexture>& envMap,
|
||||||
const TLockedToken<CTexture>& envBumpMap, const TLockedToken<CTexture>& lightmap,
|
const TLockedToken<CTexture>& envBumpMap, const TLockedToken<CTexture>& lightmap,
|
||||||
const boo::ObjToken<boo::ITextureS>& rippleMap, bool doubleLightmapBlend,
|
const std::shared_ptr<aurora::TextureHandle>& rippleMap, bool doubleLightmapBlend,
|
||||||
bool additive, u32 maxVertCount)
|
bool additive, u32 maxVertCount)
|
||||||
: m_patternTex1(patternTex1)
|
: m_patternTex1(patternTex1)
|
||||||
, m_patternTex2(patternTex2)
|
, m_patternTex2(patternTex2)
|
||||||
|
@ -210,7 +212,7 @@ CFluidPlaneShader::CFluidPlaneShader(EFluidType type, const TLockedToken<CTextur
|
||||||
m_colorTex.HasReference(), m_bumpMap.HasReference(), m_envMap.HasReference(),
|
m_colorTex.HasReference(), m_bumpMap.HasReference(), m_envMap.HasReference(),
|
||||||
m_envBumpMap.HasReference(), m_lightmap.HasReference(), m_rippleMap.operator bool(),
|
m_envBumpMap.HasReference(), m_lightmap.HasReference(), m_rippleMap.operator bool(),
|
||||||
doubleLightmapBlend, additive);
|
doubleLightmapBlend, additive);
|
||||||
m_pipelines = _cache.GetOrBuildShader(shaderInfo);
|
// m_pipelines = _cache.GetOrBuildShader(shaderInfo);
|
||||||
PrepareBinding(maxVertCount);
|
PrepareBinding(maxVertCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,70 +222,70 @@ CFluidPlaneShader::CFluidPlaneShader(const TLockedToken<CTexture>& patternTex1,
|
||||||
: m_patternTex1(patternTex1), m_patternTex2(patternTex2), m_colorTex(colorTex) {
|
: m_patternTex1(patternTex1), m_patternTex2(patternTex2), m_colorTex(colorTex) {
|
||||||
SFluidPlaneDoorShaderInfo shaderInfo(m_patternTex1.HasReference(), m_patternTex2.HasReference(),
|
SFluidPlaneDoorShaderInfo shaderInfo(m_patternTex1.HasReference(), m_patternTex2.HasReference(),
|
||||||
m_colorTex.HasReference());
|
m_colorTex.HasReference());
|
||||||
m_pipelines = _cache.GetOrBuildShader(shaderInfo);
|
// m_pipelines = _cache.GetOrBuildShader(shaderInfo);
|
||||||
PrepareBinding(maxVertCount);
|
PrepareBinding(maxVertCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CFluidPlaneShader::prepareDraw(const RenderSetupInfo& info) {
|
void CFluidPlaneShader::prepareDraw(const RenderSetupInfo& info) {
|
||||||
Uniform& uni = *reinterpret_cast<Uniform*>(m_uniBuf->map(sizeof(Uniform)));
|
// Uniform& uni = *reinterpret_cast<Uniform*>(m_uniBuf->map(sizeof(Uniform)));
|
||||||
uni.m_mv = CGraphics::g_GXModelView.toMatrix4f();
|
// uni.m_mv = CGraphics::g_GXModelView.toMatrix4f();
|
||||||
uni.m_mvNorm = info.normMtx;
|
// uni.m_mvNorm = info.normMtx;
|
||||||
uni.m_proj = CGraphics::GetPerspectiveProjectionMatrix(true);
|
// uni.m_proj = CGraphics::GetPerspectiveProjectionMatrix(true);
|
||||||
uni.m_texMtxs = info.texMtxs;
|
// uni.m_texMtxs = info.texMtxs;
|
||||||
uni.m_lighting.ActivateLights(info.lights);
|
// uni.m_lighting.ActivateLights(info.lights);
|
||||||
for (size_t i = 0; i < uni.m_lighting.colorRegs.size(); ++i) {
|
// for (size_t i = 0; i < uni.m_lighting.colorRegs.size(); ++i) {
|
||||||
uni.m_lighting.colorRegs[i] = info.kColors[i];
|
// uni.m_lighting.colorRegs[i] = info.kColors[i];
|
||||||
}
|
// }
|
||||||
uni.m_lighting.mulColor = info.kColors[3];
|
// uni.m_lighting.mulColor = info.kColors[3];
|
||||||
uni.m_lighting.fog = CGraphics::g_Fog;
|
// uni.m_lighting.fog = CGraphics::g_Fog;
|
||||||
uni.m_pad2.x() = info.indScale;
|
// uni.m_pad2.x() = info.indScale;
|
||||||
m_uniBuf->unmap();
|
// m_uniBuf->unmap();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CFluidPlaneShader::prepareDraw(const RenderSetupInfo& info, const zeus::CVector3f& waterCenter,
|
void CFluidPlaneShader::prepareDraw(const RenderSetupInfo& info, const zeus::CVector3f& waterCenter,
|
||||||
const CRippleManager& rippleManager, const zeus::CColor& colorMul,
|
const CRippleManager& rippleManager, const zeus::CColor& colorMul,
|
||||||
float rippleNormResolution) {
|
float rippleNormResolution) {
|
||||||
Uniform& uni = *reinterpret_cast<Uniform*>(m_uniBuf->map(sizeof(Uniform)));
|
// Uniform& uni = *reinterpret_cast<Uniform*>(m_uniBuf->map(sizeof(Uniform)));
|
||||||
uni.m_mv = CGraphics::g_GXModelView.toMatrix4f();
|
// uni.m_mv = CGraphics::g_GXModelView.toMatrix4f();
|
||||||
uni.m_mvNorm = info.normMtx;
|
// uni.m_mvNorm = info.normMtx;
|
||||||
uni.m_proj = CGraphics::GetPerspectiveProjectionMatrix(true);
|
// uni.m_proj = CGraphics::GetPerspectiveProjectionMatrix(true);
|
||||||
uni.m_texMtxs = info.texMtxs;
|
// uni.m_texMtxs = info.texMtxs;
|
||||||
|
//
|
||||||
size_t i = 0;
|
// size_t i = 0;
|
||||||
for (const CRipple& ripple : rippleManager.GetRipples()) {
|
// for (const CRipple& ripple : rippleManager.GetRipples()) {
|
||||||
assert(i < uni.m_ripple.size() && "Too many ripples");
|
// assert(i < uni.m_ripple.size() && "Too many ripples");
|
||||||
Ripple& rOut = uni.m_ripple[i++];
|
// Ripple& rOut = uni.m_ripple[i++];
|
||||||
if (ripple.GetTime() >= ripple.GetTimeFalloff()) {
|
// if (ripple.GetTime() >= ripple.GetTimeFalloff()) {
|
||||||
rOut.center.zeroOut();
|
// rOut.center.zeroOut();
|
||||||
rOut.params.zeroOut();
|
// rOut.params.zeroOut();
|
||||||
continue;
|
// continue;
|
||||||
}
|
// }
|
||||||
zeus::CVector3f localPos = ripple.GetCenter() - waterCenter;
|
// zeus::CVector3f localPos = ripple.GetCenter() - waterCenter;
|
||||||
rOut.center.x() = float(localPos.x());
|
// rOut.center.x() = float(localPos.x());
|
||||||
rOut.center.y() = float(localPos.y());
|
// rOut.center.y() = float(localPos.y());
|
||||||
rOut.center.z() = ripple.GetTime() * ripple.GetOOTimeFalloff();
|
// rOut.center.z() = ripple.GetTime() * ripple.GetOOTimeFalloff();
|
||||||
rOut.center.w() = ripple.GetOODistanceFalloff();
|
// rOut.center.w() = ripple.GetOODistanceFalloff();
|
||||||
rOut.params.x() = ripple.GetAmplitude();
|
// rOut.params.x() = ripple.GetAmplitude();
|
||||||
rOut.params.y() = ripple.GetPhase();
|
// rOut.params.y() = ripple.GetPhase();
|
||||||
rOut.params.z() =
|
// rOut.params.z() =
|
||||||
(1.f - ripple.GetTime() * ripple.GetOOTimeFalloff() * ripple.GetOOTimeFalloff()) * ripple.GetFrequency();
|
// (1.f - ripple.GetTime() * ripple.GetOOTimeFalloff() * ripple.GetOOTimeFalloff()) * ripple.GetFrequency();
|
||||||
}
|
// }
|
||||||
uni.m_colorMul = colorMul;
|
// uni.m_colorMul = colorMul;
|
||||||
uni.m_pad[0].x() = rippleNormResolution;
|
// uni.m_pad[0].x() = rippleNormResolution;
|
||||||
uni.m_lighting.ActivateLights(info.lights);
|
// uni.m_lighting.ActivateLights(info.lights);
|
||||||
for (i = 0; i < uni.m_lighting.colorRegs.size(); ++i) {
|
// for (i = 0; i < uni.m_lighting.colorRegs.size(); ++i) {
|
||||||
uni.m_lighting.colorRegs[i] = info.kColors[i];
|
// uni.m_lighting.colorRegs[i] = info.kColors[i];
|
||||||
}
|
// }
|
||||||
uni.m_lighting.mulColor = info.kColors[3];
|
// uni.m_lighting.mulColor = info.kColors[3];
|
||||||
uni.m_lighting.fog = CGraphics::g_Fog;
|
// uni.m_lighting.fog = CGraphics::g_Fog;
|
||||||
uni.m_pad2.x() = info.indScale;
|
// uni.m_pad2.x() = info.indScale;
|
||||||
m_uniBuf->unmap();
|
// m_uniBuf->unmap();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CFluidPlaneShader::loadVerts(const std::vector<Vertex>& verts, const std::vector<PatchVertex>& pVerts) {
|
void CFluidPlaneShader::loadVerts(const std::vector<Vertex>& verts, const std::vector<PatchVertex>& pVerts) {
|
||||||
m_vbo->load(verts.data(), verts.size() * sizeof(Vertex));
|
// m_vbo->load(verts.data(), verts.size() * sizeof(Vertex));
|
||||||
if (m_pvbo)
|
// if (m_pvbo)
|
||||||
m_pvbo->load(pVerts.data(), pVerts.size() * sizeof(PatchVertex));
|
// m_pvbo->load(pVerts.data(), pVerts.size() * sizeof(PatchVertex));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace metaforce
|
} // namespace metaforce
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
#include "Shaders/shader_CFluidPlaneShader.hpp"
|
#include "Shaders/shader_CFluidPlaneShader.hpp"
|
||||||
|
|
||||||
#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
//#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
||||||
|
|
||||||
#include <zeus/CColor.hpp>
|
#include <zeus/CColor.hpp>
|
||||||
#include <zeus/CMatrix4f.hpp>
|
#include <zeus/CMatrix4f.hpp>
|
||||||
|
@ -53,34 +53,34 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct ShaderPair {
|
// struct ShaderPair {
|
||||||
boo::ObjToken<boo::IShaderPipeline> m_regular;
|
// boo::ObjToken<boo::IShaderPipeline> m_regular;
|
||||||
boo::ObjToken<boo::IShaderPipeline> m_tessellation;
|
// boo::ObjToken<boo::IShaderPipeline> m_tessellation;
|
||||||
void reset() {
|
// void reset() {
|
||||||
m_regular.reset();
|
// m_regular.reset();
|
||||||
m_tessellation.reset();
|
// m_tessellation.reset();
|
||||||
}
|
// }
|
||||||
};
|
// };
|
||||||
|
//
|
||||||
|
// struct BindingPair {
|
||||||
|
// boo::ObjToken<boo::IShaderDataBinding> m_regular;
|
||||||
|
// boo::ObjToken<boo::IShaderDataBinding> m_tessellation;
|
||||||
|
// };
|
||||||
|
|
||||||
struct BindingPair {
|
// class Cache {
|
||||||
boo::ObjToken<boo::IShaderDataBinding> m_regular;
|
// std::array<ShaderPair, 1024> m_cache{};
|
||||||
boo::ObjToken<boo::IShaderDataBinding> m_tessellation;
|
// 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]; }
|
||||||
class Cache {
|
// static u16 MakeCacheKey(const SFluidPlaneShaderInfo& info);
|
||||||
std::array<ShaderPair, 1024> m_cache{};
|
// static u16 MakeCacheKey(const SFluidPlaneDoorShaderInfo& info);
|
||||||
std::array<ShaderPair, 8> m_doorCache{};
|
//
|
||||||
ShaderPair& CacheSlot(const SFluidPlaneShaderInfo& info, int i) { return m_cache[i]; }
|
// public:
|
||||||
ShaderPair& CacheSlot(const SFluidPlaneDoorShaderInfo& info, int i) { return m_doorCache[i]; }
|
// template <class T>
|
||||||
static u16 MakeCacheKey(const SFluidPlaneShaderInfo& info);
|
// ShaderPair GetOrBuildShader(const T& info);
|
||||||
static u16 MakeCacheKey(const SFluidPlaneDoorShaderInfo& info);
|
// void Clear();
|
||||||
|
// };
|
||||||
public:
|
// static Cache _cache;
|
||||||
template <class T>
|
|
||||||
ShaderPair GetOrBuildShader(const T& info);
|
|
||||||
void Clear();
|
|
||||||
};
|
|
||||||
static Cache _cache;
|
|
||||||
|
|
||||||
struct Ripple {
|
struct Ripple {
|
||||||
zeus::CVector4f center; // time, distFalloff
|
zeus::CVector4f center; // time, distFalloff
|
||||||
|
@ -106,34 +106,34 @@ private:
|
||||||
TLockedToken<CTexture> m_envMap;
|
TLockedToken<CTexture> m_envMap;
|
||||||
TLockedToken<CTexture> m_envBumpMap;
|
TLockedToken<CTexture> m_envBumpMap;
|
||||||
TLockedToken<CTexture> m_lightmap;
|
TLockedToken<CTexture> m_lightmap;
|
||||||
boo::ObjToken<boo::ITextureS> m_rippleMap;
|
std::shared_ptr<aurora::TextureHandle> m_rippleMap;
|
||||||
boo::ObjToken<boo::IGraphicsBufferD> m_vbo;
|
// boo::ObjToken<boo::IGraphicsBufferD> m_vbo;
|
||||||
boo::ObjToken<boo::IGraphicsBufferD> m_pvbo;
|
// boo::ObjToken<boo::IGraphicsBufferD> m_pvbo;
|
||||||
boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
|
// boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
|
||||||
ShaderPair m_pipelines;
|
// ShaderPair m_pipelines;
|
||||||
BindingPair m_dataBind;
|
// BindingPair m_dataBind;
|
||||||
int m_lastBind = -1;
|
int m_lastBind = -1;
|
||||||
|
|
||||||
#if BOO_HAS_GL
|
//#if BOO_HAS_GL
|
||||||
static ShaderPair BuildShader(boo::GLDataFactory::Context& ctx, const SFluidPlaneShaderInfo& info);
|
// static ShaderPair BuildShader(boo::GLDataFactory::Context& ctx, const SFluidPlaneShaderInfo& info);
|
||||||
static ShaderPair BuildShader(boo::GLDataFactory::Context& ctx, const SFluidPlaneDoorShaderInfo& info);
|
// static ShaderPair BuildShader(boo::GLDataFactory::Context& ctx, const SFluidPlaneDoorShaderInfo& info);
|
||||||
BindingPair BuildBinding(boo::GLDataFactory::Context& ctx, const ShaderPair& pipeline);
|
// BindingPair BuildBinding(boo::GLDataFactory::Context& ctx, const ShaderPair& pipeline);
|
||||||
#endif
|
//#endif
|
||||||
#if _WIN32
|
//#if _WIN32
|
||||||
static ShaderPair BuildShader(boo::D3D11DataFactory::Context& ctx, const SFluidPlaneShaderInfo& info);
|
// static ShaderPair BuildShader(boo::D3D11DataFactory::Context& ctx, const SFluidPlaneShaderInfo& info);
|
||||||
static ShaderPair BuildShader(boo::D3D11DataFactory::Context& ctx, const SFluidPlaneDoorShaderInfo& info);
|
// static ShaderPair BuildShader(boo::D3D11DataFactory::Context& ctx, const SFluidPlaneDoorShaderInfo& info);
|
||||||
BindingPair BuildBinding(boo::D3D11DataFactory::Context& ctx, const ShaderPair& pipeline);
|
// BindingPair BuildBinding(boo::D3D11DataFactory::Context& ctx, const ShaderPair& pipeline);
|
||||||
#endif
|
//#endif
|
||||||
#if BOO_HAS_METAL
|
//#if BOO_HAS_METAL
|
||||||
static ShaderPair BuildShader(boo::MetalDataFactory::Context& ctx, const SFluidPlaneShaderInfo& info);
|
// static ShaderPair BuildShader(boo::MetalDataFactory::Context& ctx, const SFluidPlaneShaderInfo& info);
|
||||||
static ShaderPair BuildShader(boo::MetalDataFactory::Context& ctx, const SFluidPlaneDoorShaderInfo& info);
|
// static ShaderPair BuildShader(boo::MetalDataFactory::Context& ctx, const SFluidPlaneDoorShaderInfo& info);
|
||||||
BindingPair BuildBinding(boo::MetalDataFactory::Context& ctx, const ShaderPair& pipeline);
|
// BindingPair BuildBinding(boo::MetalDataFactory::Context& ctx, const ShaderPair& pipeline);
|
||||||
#endif
|
//#endif
|
||||||
#if BOO_HAS_VULKAN
|
//#if BOO_HAS_VULKAN
|
||||||
static ShaderPair BuildShader(boo::VulkanDataFactory::Context& ctx, const SFluidPlaneShaderInfo& info);
|
// static ShaderPair BuildShader(boo::VulkanDataFactory::Context& ctx, const SFluidPlaneShaderInfo& info);
|
||||||
static ShaderPair BuildShader(boo::VulkanDataFactory::Context& ctx, const SFluidPlaneDoorShaderInfo& info);
|
// static ShaderPair BuildShader(boo::VulkanDataFactory::Context& ctx, const SFluidPlaneDoorShaderInfo& info);
|
||||||
BindingPair BuildBinding(boo::VulkanDataFactory::Context& ctx, const ShaderPair& pipeline);
|
// BindingPair BuildBinding(boo::VulkanDataFactory::Context& ctx, const ShaderPair& pipeline);
|
||||||
#endif
|
//#endif
|
||||||
|
|
||||||
template <class F>
|
template <class F>
|
||||||
static void _Shutdown();
|
static void _Shutdown();
|
||||||
|
@ -145,7 +145,7 @@ public:
|
||||||
const TLockedToken<CTexture>& patternTex2, const TLockedToken<CTexture>& colorTex,
|
const TLockedToken<CTexture>& patternTex2, const TLockedToken<CTexture>& colorTex,
|
||||||
const TLockedToken<CTexture>& bumpMap, const TLockedToken<CTexture>& envMap,
|
const TLockedToken<CTexture>& bumpMap, const TLockedToken<CTexture>& envMap,
|
||||||
const TLockedToken<CTexture>& envBumpMap, const TLockedToken<CTexture>& lightmap,
|
const TLockedToken<CTexture>& envBumpMap, const TLockedToken<CTexture>& lightmap,
|
||||||
const boo::ObjToken<boo::ITextureS>& rippleMap, bool doubleLightmapBlend, bool additive,
|
const std::shared_ptr<aurora::TextureHandle>& rippleMap, bool doubleLightmapBlend, bool additive,
|
||||||
u32 maxVertCount);
|
u32 maxVertCount);
|
||||||
CFluidPlaneShader(const TLockedToken<CTexture>& patternTex1, const TLockedToken<CTexture>& patternTex2,
|
CFluidPlaneShader(const TLockedToken<CTexture>& patternTex1, const TLockedToken<CTexture>& patternTex2,
|
||||||
const TLockedToken<CTexture>& colorTex, u32 maxVertCount);
|
const TLockedToken<CTexture>& colorTex, u32 maxVertCount);
|
||||||
|
@ -154,13 +154,13 @@ public:
|
||||||
const zeus::CColor& colorMul, float rippleNormResolution);
|
const zeus::CColor& colorMul, float rippleNormResolution);
|
||||||
void bindRegular() {
|
void bindRegular() {
|
||||||
if (m_lastBind != 0) {
|
if (m_lastBind != 0) {
|
||||||
CGraphics::SetShaderDataBinding(m_dataBind.m_regular);
|
// CGraphics::SetShaderDataBinding(m_dataBind.m_regular);
|
||||||
m_lastBind = 0;
|
m_lastBind = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool bindTessellation() {
|
bool bindTessellation() {
|
||||||
if (m_lastBind != 1) {
|
if (m_lastBind != 1) {
|
||||||
CGraphics::SetShaderDataBinding(m_dataBind.m_tessellation);
|
// CGraphics::SetShaderDataBinding(m_dataBind.m_tessellation);
|
||||||
m_lastBind = 1;
|
m_lastBind = 1;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -168,7 +168,8 @@ public:
|
||||||
void doneDrawing() { m_lastBind = -1; }
|
void doneDrawing() { m_lastBind = -1; }
|
||||||
void loadVerts(const std::vector<Vertex>& verts, const std::vector<PatchVertex>& pVerts);
|
void loadVerts(const std::vector<Vertex>& verts, const std::vector<PatchVertex>& pVerts);
|
||||||
bool isReady() const {
|
bool isReady() const {
|
||||||
return m_pipelines.m_regular->isReady() && (!m_pipelines.m_tessellation || m_pipelines.m_tessellation->isReady());
|
// return m_pipelines.m_regular->isReady() && (!m_pipelines.m_tessellation || m_pipelines.m_tessellation->isReady());
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Shutdown();
|
static void Shutdown();
|
||||||
|
|
|
@ -6,72 +6,72 @@
|
||||||
#include "Runtime/Graphics/CBooRenderer.hpp"
|
#include "Runtime/Graphics/CBooRenderer.hpp"
|
||||||
#include "Runtime/Graphics/CGraphics.hpp"
|
#include "Runtime/Graphics/CGraphics.hpp"
|
||||||
|
|
||||||
#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
//#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
||||||
#include <hecl/Pipeline.hpp>
|
//#include <hecl/Pipeline.hpp>
|
||||||
#include <zeus/CColor.hpp>
|
#include <zeus/CColor.hpp>
|
||||||
|
|
||||||
namespace metaforce {
|
namespace metaforce {
|
||||||
|
|
||||||
static boo::ObjToken<boo::IShaderPipeline> s_1WayPipeline;
|
//static boo::ObjToken<boo::IShaderPipeline> s_1WayPipeline;
|
||||||
static boo::ObjToken<boo::IShaderPipeline> s_2WayPipeline;
|
//static boo::ObjToken<boo::IShaderPipeline> s_2WayPipeline;
|
||||||
|
|
||||||
void CFogVolumeFilter::Initialize() {
|
void CFogVolumeFilter::Initialize() {
|
||||||
s_1WayPipeline = hecl::conv->convert(Shader_CFogVolumeFilter1Way{});
|
// s_1WayPipeline = hecl::conv->convert(Shader_CFogVolumeFilter1Way{});
|
||||||
s_2WayPipeline = hecl::conv->convert(Shader_CFogVolumeFilter2Way{});
|
// s_2WayPipeline = hecl::conv->convert(Shader_CFogVolumeFilter2Way{});
|
||||||
}
|
}
|
||||||
|
|
||||||
void CFogVolumeFilter::Shutdown() {
|
void CFogVolumeFilter::Shutdown() {
|
||||||
s_1WayPipeline.reset();
|
// s_1WayPipeline.reset();
|
||||||
s_2WayPipeline.reset();
|
// s_2WayPipeline.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
CFogVolumeFilter::CFogVolumeFilter() {
|
CFogVolumeFilter::CFogVolumeFilter() {
|
||||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
// CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
||||||
struct Vert {
|
// struct Vert {
|
||||||
zeus::CVector2f m_pos;
|
// zeus::CVector2f m_pos;
|
||||||
zeus::CVector2f m_uv;
|
// zeus::CVector2f m_uv;
|
||||||
};
|
// };
|
||||||
constexpr std::array<Vert, 4> verts{{
|
// constexpr std::array<Vert, 4> verts{{
|
||||||
{{-1.0, -1.0}, {0.0, 0.0}},
|
// {{-1.0, -1.0}, {0.0, 0.0}},
|
||||||
{{-1.0, 1.0}, {0.0, 1.0}},
|
// {{-1.0, 1.0}, {0.0, 1.0}},
|
||||||
{{1.0, -1.0}, {1.0, 0.0}},
|
// {{1.0, -1.0}, {1.0, 0.0}},
|
||||||
{{1.0, 1.0}, {1.0, 1.0}},
|
// {{1.0, 1.0}, {1.0, 1.0}},
|
||||||
}};
|
// }};
|
||||||
m_vbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, verts.data(), sizeof(Vert), verts.size());
|
// m_vbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, verts.data(), sizeof(Vert), verts.size());
|
||||||
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(zeus::CColor), 1);
|
// m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(zeus::CColor), 1);
|
||||||
const std::array<boo::ObjToken<boo::ITexture>, 3> texs{
|
// const std::array<boo::ObjToken<boo::ITexture>, 3> texs{
|
||||||
CGraphics::g_SpareTexture.get(),
|
// CGraphics::g_SpareTexture.get(),
|
||||||
CGraphics::g_SpareTexture.get(),
|
// CGraphics::g_SpareTexture.get(),
|
||||||
g_Renderer->GetFogRampTex().get(),
|
// g_Renderer->GetFogRampTex().get(),
|
||||||
};
|
// };
|
||||||
constexpr std::array bindIdxs{0, 1, 0};
|
// constexpr std::array bindIdxs{0, 1, 0};
|
||||||
constexpr std::array bindDepth{true, true, false};
|
// constexpr std::array bindDepth{true, true, false};
|
||||||
const std::array<boo::ObjToken<boo::IGraphicsBuffer>, 1> ubufs{m_uniBuf.get()};
|
// const std::array<boo::ObjToken<boo::IGraphicsBuffer>, 1> ubufs{m_uniBuf.get()};
|
||||||
|
//
|
||||||
m_dataBind1Way =
|
// m_dataBind1Way =
|
||||||
ctx.newShaderDataBinding(s_1WayPipeline, m_vbo.get(), nullptr, nullptr, ubufs.size(), ubufs.data(), nullptr,
|
// ctx.newShaderDataBinding(s_1WayPipeline, m_vbo.get(), nullptr, nullptr, ubufs.size(), ubufs.data(), nullptr,
|
||||||
nullptr, nullptr, texs.size(), texs.data(), bindIdxs.data(), bindDepth.data());
|
// nullptr, nullptr, texs.size(), texs.data(), bindIdxs.data(), bindDepth.data());
|
||||||
m_dataBind2Way =
|
// m_dataBind2Way =
|
||||||
ctx.newShaderDataBinding(s_2WayPipeline, m_vbo.get(), nullptr, nullptr, ubufs.size(), ubufs.data(), nullptr,
|
// ctx.newShaderDataBinding(s_2WayPipeline, m_vbo.get(), nullptr, nullptr, ubufs.size(), ubufs.data(), nullptr,
|
||||||
nullptr, nullptr, texs.size(), texs.data(), bindIdxs.data(), bindDepth.data());
|
// nullptr, nullptr, texs.size(), texs.data(), bindIdxs.data(), bindDepth.data());
|
||||||
return true;
|
// return true;
|
||||||
} BooTrace);
|
// } BooTrace);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CFogVolumeFilter::draw2WayPass(const zeus::CColor& color) {
|
void CFogVolumeFilter::draw2WayPass(const zeus::CColor& color) {
|
||||||
SCOPED_GRAPHICS_DEBUG_GROUP("CFogVolumeFilter::draw2WayPass", zeus::skMagenta);
|
SCOPED_GRAPHICS_DEBUG_GROUP("CFogVolumeFilter::draw2WayPass", zeus::skMagenta);
|
||||||
|
|
||||||
m_uniBuf->load(&color, sizeof(zeus::CColor));
|
// m_uniBuf->load(&color, sizeof(zeus::CColor));
|
||||||
CGraphics::SetShaderDataBinding(m_dataBind2Way);
|
// CGraphics::SetShaderDataBinding(m_dataBind2Way);
|
||||||
CGraphics::DrawArray(0, 4);
|
// CGraphics::DrawArray(0, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CFogVolumeFilter::draw1WayPass(const zeus::CColor& color) {
|
void CFogVolumeFilter::draw1WayPass(const zeus::CColor& color) {
|
||||||
SCOPED_GRAPHICS_DEBUG_GROUP("CFogVolumeFilter::draw1WayPass", zeus::skMagenta);
|
SCOPED_GRAPHICS_DEBUG_GROUP("CFogVolumeFilter::draw1WayPass", zeus::skMagenta);
|
||||||
|
|
||||||
m_uniBuf->load(&color, sizeof(zeus::CColor));
|
// m_uniBuf->load(&color, sizeof(zeus::CColor));
|
||||||
CGraphics::SetShaderDataBinding(m_dataBind1Way);
|
// CGraphics::SetShaderDataBinding(m_dataBind1Way);
|
||||||
CGraphics::DrawArray(0, 4);
|
// CGraphics::DrawArray(0, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace metaforce
|
} // namespace metaforce
|
||||||
|
|
|
@ -1,24 +1,16 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <boo/BooObject.hpp>
|
|
||||||
|
|
||||||
namespace boo {
|
|
||||||
struct IGraphicsBufferD;
|
|
||||||
struct IGraphicsBufferS;
|
|
||||||
struct IShaderDataBinding;
|
|
||||||
} // namespace boo
|
|
||||||
|
|
||||||
namespace zeus {
|
namespace zeus {
|
||||||
class CColor;
|
class CColor;
|
||||||
}
|
} // namespace zeus
|
||||||
|
|
||||||
namespace metaforce {
|
namespace metaforce {
|
||||||
|
|
||||||
class CFogVolumeFilter {
|
class CFogVolumeFilter {
|
||||||
boo::ObjToken<boo::IGraphicsBufferS> m_vbo;
|
// boo::ObjToken<boo::IGraphicsBufferS> m_vbo;
|
||||||
boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
|
// boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
|
||||||
boo::ObjToken<boo::IShaderDataBinding> m_dataBind1Way;
|
// boo::ObjToken<boo::IShaderDataBinding> m_dataBind1Way;
|
||||||
boo::ObjToken<boo::IShaderDataBinding> m_dataBind2Way;
|
// boo::ObjToken<boo::IShaderDataBinding> m_dataBind2Way;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void Initialize();
|
static void Initialize();
|
||||||
|
|
|
@ -2,42 +2,42 @@
|
||||||
|
|
||||||
#include "Runtime/Graphics/CGraphics.hpp"
|
#include "Runtime/Graphics/CGraphics.hpp"
|
||||||
|
|
||||||
#include <hecl/Pipeline.hpp>
|
//#include <hecl/Pipeline.hpp>
|
||||||
|
|
||||||
namespace metaforce {
|
namespace metaforce {
|
||||||
|
|
||||||
static std::array<boo::ObjToken<boo::IShaderPipeline>, 4> s_Pipelines;
|
//static std::array<boo::ObjToken<boo::IShaderPipeline>, 4> s_Pipelines;
|
||||||
|
//
|
||||||
void CFogVolumePlaneShader::Initialize() {
|
//void CFogVolumePlaneShader::Initialize() {
|
||||||
s_Pipelines[0] = hecl::conv->convert(Shader_CFogVolumePlaneShader0{});
|
// s_Pipelines[0] = hecl::conv->convert(Shader_CFogVolumePlaneShader0{});
|
||||||
s_Pipelines[1] = hecl::conv->convert(Shader_CFogVolumePlaneShader1{});
|
// s_Pipelines[1] = hecl::conv->convert(Shader_CFogVolumePlaneShader1{});
|
||||||
s_Pipelines[2] = hecl::conv->convert(Shader_CFogVolumePlaneShader2{});
|
// s_Pipelines[2] = hecl::conv->convert(Shader_CFogVolumePlaneShader2{});
|
||||||
s_Pipelines[3] = hecl::conv->convert(Shader_CFogVolumePlaneShader3{});
|
// s_Pipelines[3] = hecl::conv->convert(Shader_CFogVolumePlaneShader3{});
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
void CFogVolumePlaneShader::Shutdown() {
|
//void CFogVolumePlaneShader::Shutdown() {
|
||||||
s_Pipelines[0].reset();
|
// s_Pipelines[0].reset();
|
||||||
s_Pipelines[1].reset();
|
// s_Pipelines[1].reset();
|
||||||
s_Pipelines[2].reset();
|
// s_Pipelines[2].reset();
|
||||||
s_Pipelines[3].reset();
|
// s_Pipelines[3].reset();
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
void CFogVolumePlaneShader::CommitResources(size_t capacity) {
|
//void CFogVolumePlaneShader::CommitResources(size_t capacity) {
|
||||||
m_vertCapacity = capacity;
|
// m_vertCapacity = capacity;
|
||||||
CGraphics::CommitResources([this, capacity](boo::IGraphicsDataFactory::Context& ctx) {
|
// CGraphics::CommitResources([this, capacity](boo::IGraphicsDataFactory::Context& ctx) {
|
||||||
m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(zeus::CVector4f), capacity);
|
// m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(zeus::CVector4f), capacity);
|
||||||
for (size_t i = 0; i < m_dataBinds.size(); ++i) {
|
// 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,
|
// m_dataBinds[i] = ctx.newShaderDataBinding(s_Pipelines[i], m_vbo.get(), nullptr, nullptr, 0, nullptr, nullptr,
|
||||||
nullptr, nullptr, 0, nullptr, nullptr, nullptr);
|
// nullptr, nullptr, 0, nullptr, nullptr, nullptr);
|
||||||
}
|
// }
|
||||||
return true;
|
// return true;
|
||||||
} BooTrace);
|
// } BooTrace);
|
||||||
}
|
//}
|
||||||
|
|
||||||
void CFogVolumePlaneShader::addFan(const zeus::CVector3f* verts, int numVerts) {
|
void CFogVolumePlaneShader::addFan(const zeus::CVector3f* verts, int numVerts) {
|
||||||
zeus::CMatrix4f proj = CGraphics::GetPerspectiveProjectionMatrix(true);
|
zeus::CMatrix4f proj = CGraphics::GetPerspectiveProjectionMatrix(true);
|
||||||
zeus::CVector4f vert0 = proj * zeus::CVector4f(CGraphics::g_GXModelView * verts[0]);
|
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(m_verts.back());
|
||||||
m_verts.push_back(vert0);
|
m_verts.push_back(vert0);
|
||||||
if (m_verts.size() & 1)
|
if (m_verts.size() & 1)
|
||||||
|
@ -53,13 +53,13 @@ void CFogVolumePlaneShader::draw(int pass) {
|
||||||
if (m_verts.empty())
|
if (m_verts.empty())
|
||||||
return;
|
return;
|
||||||
SCOPED_GRAPHICS_DEBUG_GROUP("CFogVolumePlaneShader::draw", zeus::skMagenta);
|
SCOPED_GRAPHICS_DEBUG_GROUP("CFogVolumePlaneShader::draw", zeus::skMagenta);
|
||||||
if (pass == 0) {
|
// if (pass == 0) {
|
||||||
if (m_vertCapacity < m_verts.size())
|
// if (m_vertCapacity < m_verts.size())
|
||||||
CommitResources(m_verts.size());
|
// CommitResources(m_verts.size());
|
||||||
m_vbo->load(m_verts.data(), m_verts.size() * sizeof(zeus::CVector4f));
|
// m_vbo->load(m_verts.data(), m_verts.size() * sizeof(zeus::CVector4f));
|
||||||
}
|
// }
|
||||||
CGraphics::SetShaderDataBinding(m_dataBinds[pass]);
|
// CGraphics::SetShaderDataBinding(m_dataBinds[pass]);
|
||||||
CGraphics::DrawArray(0, m_verts.size());
|
// CGraphics::DrawArray(0, m_verts.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace metaforce
|
} // namespace metaforce
|
||||||
|
|
|
@ -4,28 +4,25 @@
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
//#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
||||||
|
|
||||||
#include <zeus/CRectangle.hpp>
|
#include <zeus/CRectangle.hpp>
|
||||||
#include <zeus/CVector4f.hpp>
|
#include <zeus/CVector4f.hpp>
|
||||||
|
|
||||||
namespace zeus {
|
namespace zeus {
|
||||||
class CVector3f;
|
class CVector3f;
|
||||||
}
|
} // namespace zeus
|
||||||
|
|
||||||
namespace metaforce {
|
namespace metaforce {
|
||||||
|
|
||||||
class CFogVolumePlaneShader {
|
class CFogVolumePlaneShader {
|
||||||
boo::ObjToken<boo::IGraphicsBufferD> m_vbo;
|
// boo::ObjToken<boo::IGraphicsBufferD> m_vbo;
|
||||||
std::array<boo::ObjToken<boo::IShaderDataBinding>, 4> m_dataBinds;
|
// std::array<boo::ObjToken<boo::IShaderDataBinding>, 4> m_dataBinds;
|
||||||
std::vector<zeus::CVector4f> m_verts;
|
|
||||||
size_t m_vertCapacity = 0;
|
size_t m_vertCapacity = 0;
|
||||||
|
public:
|
||||||
void CommitResources(size_t capacity);
|
std::vector<zeus::CVector4f> m_verts;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void Initialize();
|
|
||||||
static void Shutdown();
|
|
||||||
static const zeus::CRectangle DefaultRect;
|
static const zeus::CRectangle DefaultRect;
|
||||||
void reset(int numVerts) {
|
void reset(int numVerts) {
|
||||||
m_verts.clear();
|
m_verts.clear();
|
||||||
|
|
|
@ -4,113 +4,113 @@
|
||||||
|
|
||||||
#include "Runtime/Graphics/CLineRenderer.hpp"
|
#include "Runtime/Graphics/CLineRenderer.hpp"
|
||||||
|
|
||||||
#include <hecl/Pipeline.hpp>
|
//#include <hecl/Pipeline.hpp>
|
||||||
|
|
||||||
namespace metaforce {
|
namespace metaforce {
|
||||||
|
|
||||||
void CLineRendererShaders::Initialize() {
|
void CLineRendererShaders::Initialize() {
|
||||||
CGraphics::CommitResources([](boo::IGraphicsDataFactory::Context& ctx) {
|
// CGraphics::CommitResources([](boo::IGraphicsDataFactory::Context& ctx) {
|
||||||
m_texAlpha = {hecl::conv->convert(ctx, Shader_CLineRendererShaderTexAlpha{}),
|
// m_texAlpha = {hecl::conv->convert(ctx, Shader_CLineRendererShaderTexAlpha{}),
|
||||||
hecl::conv->convert(ctx, Shader_CLineRendererShaderTexAlphaAWrite{})};
|
// hecl::conv->convert(ctx, Shader_CLineRendererShaderTexAlphaAWrite{})};
|
||||||
m_texAdditive = {hecl::conv->convert(ctx, Shader_CLineRendererShaderTexAdditive{}),
|
// m_texAdditive = {hecl::conv->convert(ctx, Shader_CLineRendererShaderTexAdditive{}),
|
||||||
hecl::conv->convert(ctx, Shader_CLineRendererShaderTexAdditiveAWrite{})};
|
// hecl::conv->convert(ctx, Shader_CLineRendererShaderTexAdditiveAWrite{})};
|
||||||
m_noTexAlpha = {hecl::conv->convert(ctx, Shader_CLineRendererShaderNoTexAlpha{}),
|
// m_noTexAlpha = {hecl::conv->convert(ctx, Shader_CLineRendererShaderNoTexAlpha{}),
|
||||||
hecl::conv->convert(ctx, Shader_CLineRendererShaderNoTexAlphaAWrite{})};
|
// hecl::conv->convert(ctx, Shader_CLineRendererShaderNoTexAlphaAWrite{})};
|
||||||
m_noTexAdditive = {hecl::conv->convert(ctx, Shader_CLineRendererShaderNoTexAdditive{}),
|
// m_noTexAdditive = {hecl::conv->convert(ctx, Shader_CLineRendererShaderNoTexAdditive{}),
|
||||||
hecl::conv->convert(ctx, Shader_CLineRendererShaderNoTexAdditiveAWrite{})};
|
// hecl::conv->convert(ctx, Shader_CLineRendererShaderNoTexAdditiveAWrite{})};
|
||||||
m_texAlphaZ = {hecl::conv->convert(ctx, Shader_CLineRendererShaderTexAlphaZ{}),
|
// m_texAlphaZ = {hecl::conv->convert(ctx, Shader_CLineRendererShaderTexAlphaZ{}),
|
||||||
hecl::conv->convert(ctx, Shader_CLineRendererShaderTexAlphaZAWrite{})};
|
// hecl::conv->convert(ctx, Shader_CLineRendererShaderTexAlphaZAWrite{})};
|
||||||
m_texAdditiveZ = {hecl::conv->convert(ctx, Shader_CLineRendererShaderTexAdditiveZ{}),
|
// m_texAdditiveZ = {hecl::conv->convert(ctx, Shader_CLineRendererShaderTexAdditiveZ{}),
|
||||||
hecl::conv->convert(ctx, Shader_CLineRendererShaderTexAdditiveZAWrite{})};
|
// hecl::conv->convert(ctx, Shader_CLineRendererShaderTexAdditiveZAWrite{})};
|
||||||
m_noTexAlphaZ = {hecl::conv->convert(ctx, Shader_CLineRendererShaderNoTexAlphaZ{}),
|
// m_noTexAlphaZ = {hecl::conv->convert(ctx, Shader_CLineRendererShaderNoTexAlphaZ{}),
|
||||||
hecl::conv->convert(ctx, Shader_CLineRendererShaderNoTexAlphaZAWrite{})};
|
// hecl::conv->convert(ctx, Shader_CLineRendererShaderNoTexAlphaZAWrite{})};
|
||||||
m_noTexAdditiveZ = {hecl::conv->convert(ctx, Shader_CLineRendererShaderNoTexAdditiveZ{}),
|
// m_noTexAdditiveZ = {hecl::conv->convert(ctx, Shader_CLineRendererShaderNoTexAdditiveZ{}),
|
||||||
hecl::conv->convert(ctx, Shader_CLineRendererShaderNoTexAdditiveZAWrite{})};
|
// hecl::conv->convert(ctx, Shader_CLineRendererShaderNoTexAdditiveZAWrite{})};
|
||||||
m_noTexAlphaZGEqual = {hecl::conv->convert(ctx, Shader_CLineRendererShaderNoTexAlphaZGEqual{}),
|
// m_noTexAlphaZGEqual = {hecl::conv->convert(ctx, Shader_CLineRendererShaderNoTexAlphaZGEqual{}),
|
||||||
hecl::conv->convert(ctx, Shader_CLineRendererShaderNoTexAlphaZGEqualAWrite{})};
|
// hecl::conv->convert(ctx, Shader_CLineRendererShaderNoTexAlphaZGEqualAWrite{})};
|
||||||
return true;
|
// return true;
|
||||||
} BooTrace);
|
// } BooTrace);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLineRendererShaders::Shutdown() {
|
void CLineRendererShaders::Shutdown() {
|
||||||
for (auto& s : m_texAlpha)
|
// for (auto& s : m_texAlpha)
|
||||||
s.reset();
|
// s.reset();
|
||||||
for (auto& s : m_texAdditive)
|
// for (auto& s : m_texAdditive)
|
||||||
s.reset();
|
// s.reset();
|
||||||
for (auto& s : m_noTexAlpha)
|
// for (auto& s : m_noTexAlpha)
|
||||||
s.reset();
|
// s.reset();
|
||||||
for (auto& s : m_noTexAdditive)
|
// for (auto& s : m_noTexAdditive)
|
||||||
s.reset();
|
// s.reset();
|
||||||
for (auto& s : m_texAlphaZ)
|
// for (auto& s : m_texAlphaZ)
|
||||||
s.reset();
|
// s.reset();
|
||||||
for (auto& s : m_texAdditiveZ)
|
// for (auto& s : m_texAdditiveZ)
|
||||||
s.reset();
|
// s.reset();
|
||||||
for (auto& s : m_noTexAlphaZ)
|
// for (auto& s : m_noTexAlphaZ)
|
||||||
s.reset();
|
// s.reset();
|
||||||
for (auto& s : m_noTexAdditiveZ)
|
// for (auto& s : m_noTexAdditiveZ)
|
||||||
s.reset();
|
// s.reset();
|
||||||
for (auto& s : m_noTexAlphaZGEqual)
|
// for (auto& s : m_noTexAlphaZGEqual)
|
||||||
s.reset();
|
// s.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLineRendererShaders::BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, CLineRenderer& renderer,
|
void CLineRendererShaders::BuildShaderDataBinding(CLineRenderer& renderer,
|
||||||
const boo::ObjToken<boo::ITexture>& texture, bool additive,
|
const std::shared_ptr<aurora::TextureHandle>& texture, bool additive,
|
||||||
bool zTest, bool zGEqual) {
|
bool zTest, bool zGEqual) {
|
||||||
std::array<boo::ObjToken<boo::IShaderPipeline>, 2>* pipeline = nullptr;
|
// std::array<boo::ObjToken<boo::IShaderPipeline>, 2>* pipeline = nullptr;
|
||||||
|
//
|
||||||
if (zGEqual) {
|
// if (zGEqual) {
|
||||||
pipeline = &m_noTexAlphaZGEqual;
|
// pipeline = &m_noTexAlphaZGEqual;
|
||||||
} else if (zTest) {
|
// } else if (zTest) {
|
||||||
if (texture) {
|
// if (texture) {
|
||||||
if (additive)
|
// if (additive)
|
||||||
pipeline = &m_texAdditiveZ;
|
// pipeline = &m_texAdditiveZ;
|
||||||
else
|
// else
|
||||||
pipeline = &m_texAlphaZ;
|
// pipeline = &m_texAlphaZ;
|
||||||
} else {
|
// } else {
|
||||||
if (additive)
|
// if (additive)
|
||||||
pipeline = &m_noTexAdditiveZ;
|
// pipeline = &m_noTexAdditiveZ;
|
||||||
else
|
// else
|
||||||
pipeline = &m_noTexAlphaZ;
|
// pipeline = &m_noTexAlphaZ;
|
||||||
}
|
// }
|
||||||
} else {
|
// } else {
|
||||||
if (texture) {
|
// if (texture) {
|
||||||
if (additive)
|
// if (additive)
|
||||||
pipeline = &m_texAdditive;
|
// pipeline = &m_texAdditive;
|
||||||
else
|
// else
|
||||||
pipeline = &m_texAlpha;
|
// pipeline = &m_texAlpha;
|
||||||
} else {
|
// } else {
|
||||||
if (additive)
|
// if (additive)
|
||||||
pipeline = &m_noTexAdditive;
|
// pipeline = &m_noTexAdditive;
|
||||||
else
|
// else
|
||||||
pipeline = &m_noTexAlpha;
|
// pipeline = &m_noTexAlpha;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
size_t texCount = 0;
|
// size_t texCount = 0;
|
||||||
std::array<boo::ObjToken<boo::ITexture>, 1> textures;
|
// std::array<boo::ObjToken<boo::ITexture>, 1> textures;
|
||||||
|
//
|
||||||
std::pair<boo::ObjToken<boo::IGraphicsBufferD>, hecl::VertexBufferPool<CLineRenderer::SDrawVertTex>::IndexTp>
|
// std::pair<boo::ObjToken<boo::IGraphicsBufferD>, hecl::VertexBufferPool<CLineRenderer::SDrawVertTex>::IndexTp>
|
||||||
vbufInfo;
|
// vbufInfo;
|
||||||
std::pair<boo::ObjToken<boo::IGraphicsBufferD>, hecl::UniformBufferPool<CLineRenderer::SDrawUniform>::IndexTp>
|
// std::pair<boo::ObjToken<boo::IGraphicsBufferD>, hecl::UniformBufferPool<CLineRenderer::SDrawUniform>::IndexTp>
|
||||||
ubufInfo = renderer.m_uniformBuf.getBufferInfo();
|
// ubufInfo = renderer.m_uniformBuf.getBufferInfo();
|
||||||
if (texture) {
|
// if (texture) {
|
||||||
vbufInfo = renderer.m_vertBufTex.getBufferInfo();
|
// vbufInfo = renderer.m_vertBufTex.getBufferInfo();
|
||||||
textures[0] = texture;
|
// textures[0] = texture;
|
||||||
texCount = 1;
|
// texCount = 1;
|
||||||
} else {
|
// } else {
|
||||||
vbufInfo = renderer.m_vertBufNoTex.getBufferInfo();
|
// vbufInfo = renderer.m_vertBufNoTex.getBufferInfo();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
const std::array<boo::ObjToken<boo::IGraphicsBuffer>, 1> uniforms{ubufInfo.first.get()};
|
// const std::array<boo::ObjToken<boo::IGraphicsBuffer>, 1> uniforms{ubufInfo.first.get()};
|
||||||
constexpr std::array<boo::PipelineStage, 1> stages{boo::PipelineStage::Fragment};
|
// 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> ubufOffs{size_t(ubufInfo.second)};
|
||||||
const std::array<size_t, 1> ubufSizes{sizeof(CLineRenderer::SDrawUniform)};
|
// const std::array<size_t, 1> ubufSizes{sizeof(CLineRenderer::SDrawUniform)};
|
||||||
|
//
|
||||||
for (size_t i = 0; i < renderer.m_shaderBind.size(); ++i) {
|
// for (size_t i = 0; i < renderer.m_shaderBind.size(); ++i) {
|
||||||
renderer.m_shaderBind[i] = ctx.newShaderDataBinding(
|
// renderer.m_shaderBind[i] = ctx.newShaderDataBinding(
|
||||||
(*pipeline)[i], vbufInfo.first.get(), nullptr, nullptr, uniforms.size(), uniforms.data(), stages.data(),
|
// (*pipeline)[i], vbufInfo.first.get(), nullptr, nullptr, uniforms.size(), uniforms.data(), stages.data(),
|
||||||
ubufOffs.data(), ubufSizes.data(), texCount, textures.data(), nullptr, nullptr, vbufInfo.second);
|
// ubufOffs.data(), ubufSizes.data(), texCount, textures.data(), nullptr, nullptr, vbufInfo.second);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace metaforce
|
} // namespace metaforce
|
||||||
|
|
|
@ -2,31 +2,31 @@
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
#include "Runtime/Graphics/CGraphics.hpp"
|
||||||
|
|
||||||
namespace metaforce {
|
namespace metaforce {
|
||||||
class CLineRenderer;
|
class CLineRenderer;
|
||||||
|
|
||||||
class CLineRendererShaders {
|
class CLineRendererShaders {
|
||||||
static inline std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texAlpha;
|
// static inline std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texAlpha;
|
||||||
static inline std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texAdditive;
|
// static inline std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texAdditive;
|
||||||
|
//
|
||||||
static inline std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_noTexAlpha;
|
// static inline std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_noTexAlpha;
|
||||||
static inline std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_noTexAdditive;
|
// static inline std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_noTexAdditive;
|
||||||
|
//
|
||||||
static inline std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texAlphaZ;
|
// static inline std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texAlphaZ;
|
||||||
static inline std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texAdditiveZ;
|
// static inline std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texAdditiveZ;
|
||||||
|
//
|
||||||
static inline std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_noTexAlphaZ;
|
// static inline std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_noTexAlphaZ;
|
||||||
static inline std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_noTexAdditiveZ;
|
// static inline std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_noTexAdditiveZ;
|
||||||
|
//
|
||||||
static inline std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_noTexAlphaZGEqual;
|
// static inline std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_noTexAlphaZGEqual;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void Initialize();
|
static void Initialize();
|
||||||
static void Shutdown();
|
static void Shutdown();
|
||||||
static void BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, CLineRenderer& renderer,
|
static void BuildShaderDataBinding(CLineRenderer& renderer,
|
||||||
const boo::ObjToken<boo::ITexture>& texture, bool additive, bool zTest,
|
const std::shared_ptr<aurora::TextureHandle>& texture, bool additive, bool zTest,
|
||||||
bool zGEqual);
|
bool zGEqual);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -4,33 +4,37 @@
|
||||||
|
|
||||||
#include "Runtime/Graphics/CGraphics.hpp"
|
#include "Runtime/Graphics/CGraphics.hpp"
|
||||||
|
|
||||||
#include <hecl/Pipeline.hpp>
|
//#include <hecl/Pipeline.hpp>
|
||||||
|
|
||||||
namespace metaforce {
|
namespace metaforce {
|
||||||
|
|
||||||
static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
|
//static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
|
||||||
|
|
||||||
void CMapSurfaceShader::Initialize() { s_Pipeline = hecl::conv->convert(Shader_CMapSurfaceShader{}); }
|
void CMapSurfaceShader::Initialize() {
|
||||||
|
// s_Pipeline = hecl::conv->convert(Shader_CMapSurfaceShader{});
|
||||||
|
}
|
||||||
|
|
||||||
void CMapSurfaceShader::Shutdown() { s_Pipeline.reset(); }
|
void CMapSurfaceShader::Shutdown() {
|
||||||
|
// s_Pipeline.reset();
|
||||||
|
}
|
||||||
|
|
||||||
CMapSurfaceShader::CMapSurfaceShader(boo::IGraphicsDataFactory::Context& ctx,
|
CMapSurfaceShader::CMapSurfaceShader(aurora::ArrayRef<zeus::CVector3f> vbo,
|
||||||
const boo::ObjToken<boo::IGraphicsBufferS>& vbo,
|
aurora::ArrayRef<uint16_t> ibo)
|
||||||
const boo::ObjToken<boo::IGraphicsBufferS>& ibo)
|
//: m_vbo(vbo), m_ibo(ibo)
|
||||||
: m_vbo(vbo), m_ibo(ibo) {
|
{
|
||||||
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
|
// 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::ObjToken<boo::IGraphicsBuffer>, 1> bufs{m_uniBuf.get()};
|
||||||
constexpr std::array<boo::PipelineStage, 1> stages{boo::PipelineStage::Vertex};
|
// 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(),
|
// 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);
|
// stages.data(), nullptr, nullptr, 0, nullptr, nullptr, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMapSurfaceShader::draw(const zeus::CColor& color, u32 start, u32 count) {
|
void CMapSurfaceShader::draw(const zeus::CColor& color, u32 start, u32 count) {
|
||||||
SCOPED_GRAPHICS_DEBUG_GROUP("CMapSurfaceShader::draw", zeus::skMagenta);
|
SCOPED_GRAPHICS_DEBUG_GROUP("CMapSurfaceShader::draw", zeus::skMagenta);
|
||||||
Uniform uniform = {CGraphics::GetPerspectiveProjectionMatrix(true) * CGraphics::g_GXModelView.toMatrix4f(), color};
|
Uniform uniform = {CGraphics::GetPerspectiveProjectionMatrix(true) * CGraphics::g_GXModelView.toMatrix4f(), color};
|
||||||
m_uniBuf->load(&uniform, sizeof(Uniform));
|
// m_uniBuf->load(&uniform, sizeof(Uniform));
|
||||||
CGraphics::SetShaderDataBinding(m_dataBind);
|
// CGraphics::SetShaderDataBinding(m_dataBind);
|
||||||
CGraphics::DrawArrayIndexed(start, count);
|
// CGraphics::DrawArrayIndexed(start, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace metaforce
|
} // namespace metaforce
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Runtime/GCNTypes.hpp"
|
#include "Runtime/GCNTypes.hpp"
|
||||||
|
#include "Runtime/Graphics/CGraphics.hpp"
|
||||||
#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
|
||||||
|
|
||||||
#include <zeus/CColor.hpp>
|
#include <zeus/CColor.hpp>
|
||||||
#include <zeus/CMatrix4f.hpp>
|
#include <zeus/CMatrix4f.hpp>
|
||||||
|
@ -15,16 +14,16 @@ class CMapSurfaceShader {
|
||||||
zeus::CColor color;
|
zeus::CColor color;
|
||||||
};
|
};
|
||||||
|
|
||||||
boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
|
// boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
|
||||||
boo::ObjToken<boo::IGraphicsBufferS> m_vbo;
|
// boo::ObjToken<boo::IGraphicsBufferS> m_vbo;
|
||||||
boo::ObjToken<boo::IGraphicsBufferS> m_ibo;
|
// boo::ObjToken<boo::IGraphicsBufferS> m_ibo;
|
||||||
boo::ObjToken<boo::IShaderDataBinding> m_dataBind;
|
// boo::ObjToken<boo::IShaderDataBinding> m_dataBind;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void Initialize();
|
static void Initialize();
|
||||||
static void Shutdown();
|
static void Shutdown();
|
||||||
CMapSurfaceShader(boo::IGraphicsDataFactory::Context& ctx, const boo::ObjToken<boo::IGraphicsBufferS>& vbo,
|
CMapSurfaceShader(aurora::ArrayRef<zeus::CVector3f> vbo,
|
||||||
const boo::ObjToken<boo::IGraphicsBufferS>& ibo);
|
aurora::ArrayRef<uint16_t> ibo);
|
||||||
void draw(const zeus::CColor& color, u32 start, u32 count);
|
void draw(const zeus::CColor& color, u32 start, u32 count);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -4,11 +4,11 @@
|
||||||
#include "Runtime/Graphics/CLight.hpp"
|
#include "Runtime/Graphics/CLight.hpp"
|
||||||
|
|
||||||
#include <hecl/Backend.hpp>
|
#include <hecl/Backend.hpp>
|
||||||
#include <hecl/Pipeline.hpp>
|
//#include <hecl/Pipeline.hpp>
|
||||||
|
|
||||||
namespace metaforce {
|
namespace metaforce {
|
||||||
|
|
||||||
std::unordered_map<uint64_t, CModelShaders::ShaderPipelines> CModelShaders::g_ShaderPipelines;
|
//std::unordered_map<uint64_t, CModelShaders::ShaderPipelines> CModelShaders::g_ShaderPipelines;
|
||||||
|
|
||||||
void CModelShaders::LightingUniform::ActivateLights(const std::vector<CLight>& lts) {
|
void CModelShaders::LightingUniform::ActivateLights(const std::vector<CLight>& lts) {
|
||||||
ambient = zeus::skClear;
|
ambient = zeus::skClear;
|
||||||
|
@ -80,154 +80,156 @@ constexpr std::array<hecl::Backend::TextureInfo, 2> DisintegrateTextures{{
|
||||||
{TexCoordSource::Position, 1, false}, // Ashy tex
|
{TexCoordSource::Position, 1, false}, // Ashy tex
|
||||||
}};
|
}};
|
||||||
|
|
||||||
static std::array<hecl::Backend::ExtensionSlot, size_t(EExtendedShader::MAX)> g_ExtensionSlots{{
|
//static std::array<hecl::Backend::ExtensionSlot, size_t(EExtendedShader::MAX)> g_ExtensionSlots{{
|
||||||
/* Default solid shading */
|
// /* Default solid shading */
|
||||||
{},
|
// {},
|
||||||
/* Normal lit shading */
|
// /* Normal lit shading */
|
||||||
{0, nullptr, hecl::Backend::BlendFactor::Original, hecl::Backend::BlendFactor::Original,
|
// {0, nullptr, hecl::Backend::BlendFactor::Original, hecl::Backend::BlendFactor::Original,
|
||||||
hecl::Backend::ZTest::Original, hecl::Backend::CullMode::Backface, false, false, true},
|
// hecl::Backend::ZTest::Original, hecl::Backend::CullMode::Backface, false, false, true},
|
||||||
/* Thermal model shading */
|
// /* Thermal model shading */
|
||||||
{1, ThermalTextures.data(), hecl::Backend::BlendFactor::One, hecl::Backend::BlendFactor::One,
|
// {1, ThermalTextures.data(), hecl::Backend::BlendFactor::One, hecl::Backend::BlendFactor::One,
|
||||||
hecl::Backend::ZTest::Original, hecl::Backend::CullMode::Backface, false, false, false, true},
|
// hecl::Backend::ZTest::Original, hecl::Backend::CullMode::Backface, false, false, false, true},
|
||||||
/* Thermal model shading without Z-test or Z-write */
|
// /* Thermal model shading without Z-test or Z-write */
|
||||||
{1, ThermalTextures.data(), hecl::Backend::BlendFactor::One, hecl::Backend::BlendFactor::One,
|
// {1, ThermalTextures.data(), hecl::Backend::BlendFactor::One, hecl::Backend::BlendFactor::One,
|
||||||
hecl::Backend::ZTest::None, hecl::Backend::CullMode::Backface, true, false, false, true},
|
// hecl::Backend::ZTest::None, hecl::Backend::CullMode::Backface, true, false, false, true},
|
||||||
/* Thermal static shading */
|
// /* Thermal static shading */
|
||||||
{0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::One, hecl::Backend::ZTest::Original,
|
// {0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::One, hecl::Backend::ZTest::Original,
|
||||||
hecl::Backend::CullMode::Backface, false, false, false, true, false, false, true},
|
// hecl::Backend::CullMode::Backface, false, false, false, true, false, false, true},
|
||||||
/* Thermal static shading without Z-write */
|
// /* Thermal static shading without Z-write */
|
||||||
{0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::One, hecl::Backend::ZTest::Original,
|
// {0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::One, hecl::Backend::ZTest::Original,
|
||||||
hecl::Backend::CullMode::Backface, true, false, false, true, false, false, false},
|
// hecl::Backend::CullMode::Backface, true, false, false, true, false, false, false},
|
||||||
/* Forced alpha shading */
|
// /* Forced alpha shading */
|
||||||
{0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::InvSrcAlpha,
|
// {0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::InvSrcAlpha,
|
||||||
hecl::Backend::ZTest::Original, hecl::Backend::CullMode::Backface, false, false, true},
|
// hecl::Backend::ZTest::Original, hecl::Backend::CullMode::Backface, false, false, true},
|
||||||
/* Forced additive shading */
|
// /* Forced additive shading */
|
||||||
{0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::One, hecl::Backend::ZTest::Original,
|
// {0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::One, hecl::Backend::ZTest::Original,
|
||||||
hecl::Backend::CullMode::Backface, false, false, true},
|
// hecl::Backend::CullMode::Backface, false, false, true},
|
||||||
/* Solid color */
|
// /* Solid color */
|
||||||
{0, nullptr, hecl::Backend::BlendFactor::One, hecl::Backend::BlendFactor::Zero, hecl::Backend::ZTest::LEqual,
|
// {0, nullptr, hecl::Backend::BlendFactor::One, hecl::Backend::BlendFactor::Zero, hecl::Backend::ZTest::LEqual,
|
||||||
hecl::Backend::CullMode::Backface, false, false, false},
|
// hecl::Backend::CullMode::Backface, false, false, false},
|
||||||
/* Solid color additive */
|
// /* Solid color additive */
|
||||||
{0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::One, hecl::Backend::ZTest::LEqual,
|
// {0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::One, hecl::Backend::ZTest::LEqual,
|
||||||
hecl::Backend::CullMode::Backface, true, false, true},
|
// hecl::Backend::CullMode::Backface, true, false, true},
|
||||||
/* Alpha-only Solid color frontface cull, LEqual */
|
// /* Alpha-only Solid color frontface cull, LEqual */
|
||||||
{0, nullptr, hecl::Backend::BlendFactor::Zero, hecl::Backend::BlendFactor::One, hecl::Backend::ZTest::LEqual,
|
// {0, nullptr, hecl::Backend::BlendFactor::Zero, hecl::Backend::BlendFactor::One, hecl::Backend::ZTest::LEqual,
|
||||||
hecl::Backend::CullMode::Frontface, false, true, false},
|
// hecl::Backend::CullMode::Frontface, false, true, false},
|
||||||
/* Alpha-only Solid color frontface cull, Always, No Z-write */
|
// /* Alpha-only Solid color frontface cull, Always, No Z-write */
|
||||||
{0, nullptr, hecl::Backend::BlendFactor::Zero, hecl::Backend::BlendFactor::One, hecl::Backend::ZTest::None,
|
// {0, nullptr, hecl::Backend::BlendFactor::Zero, hecl::Backend::BlendFactor::One, hecl::Backend::ZTest::None,
|
||||||
hecl::Backend::CullMode::Frontface, true, true, false},
|
// hecl::Backend::CullMode::Frontface, true, true, false},
|
||||||
/* Alpha-only Solid color backface cull, LEqual */
|
// /* Alpha-only Solid color backface cull, LEqual */
|
||||||
{0, nullptr, hecl::Backend::BlendFactor::Zero, hecl::Backend::BlendFactor::One, hecl::Backend::ZTest::LEqual,
|
// {0, nullptr, hecl::Backend::BlendFactor::Zero, hecl::Backend::BlendFactor::One, hecl::Backend::ZTest::LEqual,
|
||||||
hecl::Backend::CullMode::Backface, false, true, false},
|
// hecl::Backend::CullMode::Backface, false, true, false},
|
||||||
/* Alpha-only Solid color backface cull, Greater, No Z-write */
|
// /* Alpha-only Solid color backface cull, Greater, No Z-write */
|
||||||
{0, nullptr, hecl::Backend::BlendFactor::Zero, hecl::Backend::BlendFactor::One, hecl::Backend::ZTest::Greater,
|
// {0, nullptr, hecl::Backend::BlendFactor::Zero, hecl::Backend::BlendFactor::One, hecl::Backend::ZTest::Greater,
|
||||||
hecl::Backend::CullMode::Backface, true, true, false},
|
// hecl::Backend::CullMode::Backface, true, true, false},
|
||||||
/* MorphBall shadow shading */
|
// /* MorphBall shadow shading */
|
||||||
{3, BallFadeTextures.data(), hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::InvSrcAlpha,
|
// {3, BallFadeTextures.data(), hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::InvSrcAlpha,
|
||||||
hecl::Backend::ZTest::Equal, hecl::Backend::CullMode::Backface, false, false, true, false, true},
|
// hecl::Backend::ZTest::Equal, hecl::Backend::CullMode::Backface, false, false, true, false, true},
|
||||||
/* World shadow shading (modified lighting) */
|
// /* World shadow shading (modified lighting) */
|
||||||
{1, WorldShadowTextures.data(), hecl::Backend::BlendFactor::Original, hecl::Backend::BlendFactor::Original,
|
// {1, WorldShadowTextures.data(), hecl::Backend::BlendFactor::Original, hecl::Backend::BlendFactor::Original,
|
||||||
hecl::Backend::ZTest::Original, hecl::Backend::CullMode::Backface, false, false, true},
|
// hecl::Backend::ZTest::Original, hecl::Backend::CullMode::Backface, false, false, true},
|
||||||
/* Forced alpha shading without culling */
|
// /* Forced alpha shading without culling */
|
||||||
{0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::InvSrcAlpha,
|
// {0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::InvSrcAlpha,
|
||||||
hecl::Backend::ZTest::Original, hecl::Backend::CullMode::None, false, false, true},
|
// hecl::Backend::ZTest::Original, hecl::Backend::CullMode::None, false, false, true},
|
||||||
/* Forced additive shading without culling */
|
// /* Forced additive shading without culling */
|
||||||
{0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::One, hecl::Backend::ZTest::Original,
|
// {0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::One, hecl::Backend::ZTest::Original,
|
||||||
hecl::Backend::CullMode::None, false, false, true},
|
// hecl::Backend::CullMode::None, false, false, true},
|
||||||
/* Forced alpha shading without Z-write */
|
// /* Forced alpha shading without Z-write */
|
||||||
{0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::InvSrcAlpha,
|
// {0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::InvSrcAlpha,
|
||||||
hecl::Backend::ZTest::Original, hecl::Backend::CullMode::Original, true, false, true},
|
// hecl::Backend::ZTest::Original, hecl::Backend::CullMode::Original, true, false, true},
|
||||||
/* Forced additive shading without Z-write */
|
// /* Forced additive shading without Z-write */
|
||||||
{0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::One, hecl::Backend::ZTest::Original,
|
// {0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::One, hecl::Backend::ZTest::Original,
|
||||||
hecl::Backend::CullMode::Original, true, false, true},
|
// hecl::Backend::CullMode::Original, true, false, true},
|
||||||
/* Forced alpha shading without culling or Z-write */
|
// /* Forced alpha shading without culling or Z-write */
|
||||||
{0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::InvSrcAlpha,
|
// {0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::InvSrcAlpha,
|
||||||
hecl::Backend::ZTest::Original, hecl::Backend::CullMode::None, true, false, true},
|
// hecl::Backend::ZTest::Original, hecl::Backend::CullMode::None, true, false, true},
|
||||||
/* Forced additive shading without culling or Z-write */
|
// /* Forced additive shading without culling or Z-write */
|
||||||
{0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::One, hecl::Backend::ZTest::Original,
|
// {0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::One, hecl::Backend::ZTest::Original,
|
||||||
hecl::Backend::CullMode::None, true, false, true},
|
// hecl::Backend::CullMode::None, true, false, true},
|
||||||
/* Depth GEqual no Z-write */
|
// /* Depth GEqual no Z-write */
|
||||||
{0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::InvSrcAlpha,
|
// {0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::InvSrcAlpha,
|
||||||
hecl::Backend::ZTest::GEqual, hecl::Backend::CullMode::Backface, true, false, true},
|
// hecl::Backend::ZTest::GEqual, hecl::Backend::CullMode::Backface, true, false, true},
|
||||||
/* Disintegration */
|
// /* Disintegration */
|
||||||
{2, DisintegrateTextures.data(), hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::InvSrcAlpha,
|
// {2, DisintegrateTextures.data(), hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::InvSrcAlpha,
|
||||||
hecl::Backend::ZTest::LEqual, hecl::Backend::CullMode::Original, false, false, true, false, false, true},
|
// hecl::Backend::ZTest::LEqual, hecl::Backend::CullMode::Original, false, false, true, false, false, true},
|
||||||
/* Forced additive shading without culling or Z-write and greater depth test */
|
// /* Forced additive shading without culling or Z-write and greater depth test */
|
||||||
{0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::One, hecl::Backend::ZTest::Greater,
|
// {0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::One, hecl::Backend::ZTest::Greater,
|
||||||
hecl::Backend::CullMode::None, true, false, true},
|
// hecl::Backend::CullMode::None, true, false, true},
|
||||||
/* Thermal cold shading */
|
// /* Thermal cold shading */
|
||||||
{0, nullptr, hecl::Backend::BlendFactor::Original, hecl::Backend::BlendFactor::Original,
|
// {0, nullptr, hecl::Backend::BlendFactor::Original, hecl::Backend::BlendFactor::Original,
|
||||||
hecl::Backend::ZTest::Original, hecl::Backend::CullMode::Original, false, false, true, false, false, false, true},
|
// hecl::Backend::ZTest::Original, hecl::Backend::CullMode::Original, false, false, true, false, false, false, true},
|
||||||
/* Normal lit shading with alpha */
|
// /* Normal lit shading with alpha */
|
||||||
{0, nullptr, hecl::Backend::BlendFactor::Original, hecl::Backend::BlendFactor::Original,
|
// {0, nullptr, hecl::Backend::BlendFactor::Original, hecl::Backend::BlendFactor::Original,
|
||||||
hecl::Backend::ZTest::Original, hecl::Backend::CullMode::Backface},
|
// hecl::Backend::ZTest::Original, hecl::Backend::CullMode::Backface},
|
||||||
/* Normal lit shading with alpha without Z-write or depth test */
|
// /* Normal lit shading with alpha without Z-write or depth test */
|
||||||
{0, nullptr, hecl::Backend::BlendFactor::Original, hecl::Backend::BlendFactor::Original, hecl::Backend::ZTest::None,
|
// {0, nullptr, hecl::Backend::BlendFactor::Original, hecl::Backend::BlendFactor::Original, hecl::Backend::ZTest::None,
|
||||||
hecl::Backend::CullMode::Backface, true},
|
// hecl::Backend::CullMode::Backface, true},
|
||||||
/* Normal lit shading with cube reflection */
|
// /* Normal lit shading with cube reflection */
|
||||||
{0, nullptr, hecl::Backend::BlendFactor::Original, hecl::Backend::BlendFactor::Original,
|
// {0, nullptr, hecl::Backend::BlendFactor::Original, hecl::Backend::BlendFactor::Original,
|
||||||
hecl::Backend::ZTest::Original, hecl::Backend::CullMode::Backface, false, false, true},
|
// hecl::Backend::ZTest::Original, hecl::Backend::CullMode::Backface, false, false, true},
|
||||||
/* Normal lit shading with cube reflection and world shadow */
|
// /* Normal lit shading with cube reflection and world shadow */
|
||||||
{1, WorldShadowTextures.data(), hecl::Backend::BlendFactor::Original, hecl::Backend::BlendFactor::Original,
|
// {1, WorldShadowTextures.data(), hecl::Backend::BlendFactor::Original, hecl::Backend::BlendFactor::Original,
|
||||||
hecl::Backend::ZTest::Original, hecl::Backend::CullMode::Backface, false, false, true},
|
// hecl::Backend::ZTest::Original, hecl::Backend::CullMode::Backface, false, false, true},
|
||||||
}};
|
//}};
|
||||||
|
|
||||||
constexpr std::array<const char*, size_t(EExtendedShader::MAX)> ShaderMacros{
|
//constexpr std::array<const char*, size_t(EExtendedShader::MAX)> ShaderMacros{
|
||||||
"URDE_LIGHTING",
|
// "URDE_LIGHTING",
|
||||||
"URDE_LIGHTING",
|
// "URDE_LIGHTING",
|
||||||
"URDE_THERMAL_MODEL",
|
// "URDE_THERMAL_MODEL",
|
||||||
"URDE_THERMAL_MODEL",
|
// "URDE_THERMAL_MODEL",
|
||||||
"URDE_THERMAL_STATIC",
|
// "URDE_THERMAL_STATIC",
|
||||||
"URDE_THERMAL_STATIC",
|
// "URDE_THERMAL_STATIC",
|
||||||
"URDE_LIGHTING",
|
// "URDE_LIGHTING",
|
||||||
"URDE_LIGHTING",
|
// "URDE_LIGHTING",
|
||||||
"URDE_SOLID",
|
// "URDE_SOLID",
|
||||||
"URDE_SOLID",
|
// "URDE_SOLID",
|
||||||
"URDE_SOLID",
|
// "URDE_SOLID",
|
||||||
"URDE_SOLID",
|
// "URDE_SOLID",
|
||||||
"URDE_SOLID",
|
// "URDE_SOLID",
|
||||||
"URDE_SOLID",
|
// "URDE_SOLID",
|
||||||
"URDE_MB_SHADOW",
|
// "URDE_MB_SHADOW",
|
||||||
"URDE_LIGHTING_SHADOW",
|
// "URDE_LIGHTING_SHADOW",
|
||||||
"URDE_LIGHTING",
|
// "URDE_LIGHTING",
|
||||||
"URDE_LIGHTING",
|
// "URDE_LIGHTING",
|
||||||
"URDE_LIGHTING",
|
// "URDE_LIGHTING",
|
||||||
"URDE_LIGHTING",
|
// "URDE_LIGHTING",
|
||||||
"URDE_LIGHTING",
|
// "URDE_LIGHTING",
|
||||||
"URDE_LIGHTING",
|
// "URDE_LIGHTING",
|
||||||
"URDE_LIGHTING",
|
// "URDE_LIGHTING",
|
||||||
"URDE_DISINTEGRATE",
|
// "URDE_DISINTEGRATE",
|
||||||
"URDE_LIGHTING",
|
// "URDE_LIGHTING",
|
||||||
"URDE_THERMAL_COLD",
|
// "URDE_THERMAL_COLD",
|
||||||
"URDE_LIGHTING",
|
// "URDE_LIGHTING",
|
||||||
"URDE_LIGHTING",
|
// "URDE_LIGHTING",
|
||||||
"URDE_LIGHTING_CUBE_REFLECTION",
|
// "URDE_LIGHTING_CUBE_REFLECTION",
|
||||||
"URDE_LIGHTING_CUBE_REFLECTION_SHADOW",
|
// "URDE_LIGHTING_CUBE_REFLECTION_SHADOW",
|
||||||
};
|
//};
|
||||||
|
|
||||||
void CModelShaders::Initialize() {
|
void CModelShaders::Initialize() {
|
||||||
for (size_t i = 0; i < g_ExtensionSlots.size(); i++) {
|
// for (size_t i = 0; i < g_ExtensionSlots.size(); i++) {
|
||||||
g_ExtensionSlots[i].shaderMacro = ShaderMacros[i];
|
// g_ExtensionSlots[i].shaderMacro = ShaderMacros[i];
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
void CModelShaders::Shutdown() { g_ShaderPipelines.clear(); }
|
void CModelShaders::Shutdown() {
|
||||||
|
// g_ShaderPipelines.clear();
|
||||||
CModelShaders::ShaderPipelines CModelShaders::BuildExtendedShader(const hecl::Backend::ShaderTag& tag,
|
|
||||||
const Material& material) {
|
|
||||||
auto search = g_ShaderPipelines.find(tag.val64());
|
|
||||||
if (search != g_ShaderPipelines.cend())
|
|
||||||
return search->second;
|
|
||||||
|
|
||||||
ShaderPipelines& newPipelines = g_ShaderPipelines[tag.val64()];
|
|
||||||
newPipelines = std::make_shared<ShaderPipelinesData>();
|
|
||||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
|
||||||
size_t idx = 0;
|
|
||||||
for (const auto& ext : g_ExtensionSlots)
|
|
||||||
(*newPipelines)[idx++] = hecl::conv->convert(ctx, Shader_CModelShaders(SModelShadersInfo(material, tag, ext)));
|
|
||||||
return true;
|
|
||||||
} BooTrace);
|
|
||||||
return newPipelines;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//CModelShaders::ShaderPipelines CModelShaders::BuildExtendedShader(const hecl::Backend::ShaderTag& tag,
|
||||||
|
// const Material& material) {
|
||||||
|
// auto search = g_ShaderPipelines.find(tag.val64());
|
||||||
|
// if (search != g_ShaderPipelines.cend())
|
||||||
|
// return search->second;
|
||||||
|
//
|
||||||
|
// ShaderPipelines& newPipelines = g_ShaderPipelines[tag.val64()];
|
||||||
|
// newPipelines = std::make_shared<ShaderPipelinesData>();
|
||||||
|
// CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
||||||
|
// size_t idx = 0;
|
||||||
|
// for (const auto& ext : g_ExtensionSlots)
|
||||||
|
// (*newPipelines)[idx++] = hecl::conv->convert(ctx, Shader_CModelShaders(SModelShadersInfo(material, tag, ext)));
|
||||||
|
// return true;
|
||||||
|
// } BooTrace);
|
||||||
|
// return newPipelines;
|
||||||
|
//}
|
||||||
|
|
||||||
} // namespace metaforce
|
} // namespace metaforce
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "DataSpec/DNAMP1/CMDLMaterials.hpp"
|
//#include "DataSpec/DNAMP1/CMDLMaterials.hpp"
|
||||||
|
|
||||||
#include "Runtime/Graphics/CGraphics.hpp"
|
#include "Runtime/Graphics/CGraphics.hpp"
|
||||||
|
|
||||||
|
@ -100,14 +100,14 @@ public:
|
||||||
static void Initialize();
|
static void Initialize();
|
||||||
static void Shutdown();
|
static void Shutdown();
|
||||||
|
|
||||||
using ShaderPipelinesData = std::array<boo::ObjToken<boo::IShaderPipeline>, size_t(EExtendedShader::MAX)>;
|
// using ShaderPipelinesData = std::array<boo::ObjToken<boo::IShaderPipeline>, size_t(EExtendedShader::MAX)>;
|
||||||
using ShaderPipelines = std::shared_ptr<ShaderPipelinesData>;
|
// using ShaderPipelines = std::shared_ptr<ShaderPipelinesData>;
|
||||||
|
|
||||||
using Material = DataSpec::DNAMP1::HMDLMaterialSet::Material;
|
// using Material = DataSpec::DNAMP1::HMDLMaterialSet::Material;
|
||||||
static ShaderPipelines BuildExtendedShader(const hecl::Backend::ShaderTag& tag, const Material& material);
|
// static ShaderPipelines BuildExtendedShader(const hecl::Backend::ShaderTag& tag, const Material& material);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static std::unordered_map<uint64_t, ShaderPipelines> g_ShaderPipelines;
|
// static std::unordered_map<uint64_t, ShaderPipelines> g_ShaderPipelines;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace metaforce
|
} // namespace metaforce
|
||||||
|
|
|
@ -5,56 +5,56 @@
|
||||||
#include "Runtime/Particle/CParticleSwoosh.hpp"
|
#include "Runtime/Particle/CParticleSwoosh.hpp"
|
||||||
#include "Runtime/Particle/CSwooshDescription.hpp"
|
#include "Runtime/Particle/CSwooshDescription.hpp"
|
||||||
|
|
||||||
#include <hecl/Pipeline.hpp>
|
//#include <hecl/Pipeline.hpp>
|
||||||
|
|
||||||
namespace metaforce {
|
namespace metaforce {
|
||||||
|
|
||||||
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CParticleSwooshShaders::m_texZWrite;
|
//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_texNoZWrite;
|
||||||
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CParticleSwooshShaders::m_texAdditiveZWrite;
|
//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_texAdditiveNoZWrite;
|
||||||
|
//
|
||||||
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CParticleSwooshShaders::m_noTexZWrite;
|
//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_noTexNoZWrite;
|
||||||
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CParticleSwooshShaders::m_noTexAdditiveZWrite;
|
//std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CParticleSwooshShaders::m_noTexAdditiveZWrite;
|
||||||
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CParticleSwooshShaders::m_noTexAdditiveNoZWrite;
|
//std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CParticleSwooshShaders::m_noTexAdditiveNoZWrite;
|
||||||
|
|
||||||
void CParticleSwooshShaders::Initialize() {
|
void CParticleSwooshShaders::Initialize() {
|
||||||
m_texZWrite = {hecl::conv->convert(Shader_CParticleSwooshShaderTexZWrite{}),
|
// m_texZWrite = {hecl::conv->convert(Shader_CParticleSwooshShaderTexZWrite{}),
|
||||||
hecl::conv->convert(Shader_CParticleSwooshShaderTexZWriteAWrite{})};
|
// hecl::conv->convert(Shader_CParticleSwooshShaderTexZWriteAWrite{})};
|
||||||
m_texNoZWrite = {hecl::conv->convert(Shader_CParticleSwooshShaderTexNoZWrite{}),
|
// m_texNoZWrite = {hecl::conv->convert(Shader_CParticleSwooshShaderTexNoZWrite{}),
|
||||||
hecl::conv->convert(Shader_CParticleSwooshShaderTexNoZWriteAWrite{})};
|
// hecl::conv->convert(Shader_CParticleSwooshShaderTexNoZWriteAWrite{})};
|
||||||
m_texAdditiveZWrite = {hecl::conv->convert(Shader_CParticleSwooshShaderTexAdditiveZWrite{}),
|
// m_texAdditiveZWrite = {hecl::conv->convert(Shader_CParticleSwooshShaderTexAdditiveZWrite{}),
|
||||||
hecl::conv->convert(Shader_CParticleSwooshShaderTexAdditiveZWriteAWrite{})};
|
// hecl::conv->convert(Shader_CParticleSwooshShaderTexAdditiveZWriteAWrite{})};
|
||||||
m_texAdditiveNoZWrite = {hecl::conv->convert(Shader_CParticleSwooshShaderTexAdditiveNoZWrite{}),
|
// m_texAdditiveNoZWrite = {hecl::conv->convert(Shader_CParticleSwooshShaderTexAdditiveNoZWrite{}),
|
||||||
hecl::conv->convert(Shader_CParticleSwooshShaderTexAdditiveNoZWriteAWrite{})};
|
// hecl::conv->convert(Shader_CParticleSwooshShaderTexAdditiveNoZWriteAWrite{})};
|
||||||
m_noTexZWrite = {hecl::conv->convert(Shader_CParticleSwooshShaderNoTexZWrite{}),
|
// m_noTexZWrite = {hecl::conv->convert(Shader_CParticleSwooshShaderNoTexZWrite{}),
|
||||||
hecl::conv->convert(Shader_CParticleSwooshShaderNoTexZWriteAWrite{})};
|
// hecl::conv->convert(Shader_CParticleSwooshShaderNoTexZWriteAWrite{})};
|
||||||
m_noTexNoZWrite = {hecl::conv->convert(Shader_CParticleSwooshShaderNoTexNoZWrite{}),
|
// m_noTexNoZWrite = {hecl::conv->convert(Shader_CParticleSwooshShaderNoTexNoZWrite{}),
|
||||||
hecl::conv->convert(Shader_CParticleSwooshShaderNoTexNoZWriteAWrite{})};
|
// hecl::conv->convert(Shader_CParticleSwooshShaderNoTexNoZWriteAWrite{})};
|
||||||
m_noTexAdditiveZWrite = {hecl::conv->convert(Shader_CParticleSwooshShaderNoTexAdditiveZWrite{}),
|
// m_noTexAdditiveZWrite = {hecl::conv->convert(Shader_CParticleSwooshShaderNoTexAdditiveZWrite{}),
|
||||||
hecl::conv->convert(Shader_CParticleSwooshShaderNoTexAdditiveZWriteAWrite{})};
|
// hecl::conv->convert(Shader_CParticleSwooshShaderNoTexAdditiveZWriteAWrite{})};
|
||||||
m_noTexAdditiveNoZWrite = {hecl::conv->convert(Shader_CParticleSwooshShaderNoTexAdditiveNoZWrite{}),
|
// m_noTexAdditiveNoZWrite = {hecl::conv->convert(Shader_CParticleSwooshShaderNoTexAdditiveNoZWrite{}),
|
||||||
hecl::conv->convert(Shader_CParticleSwooshShaderNoTexAdditiveNoZWriteAWrite{})};
|
// hecl::conv->convert(Shader_CParticleSwooshShaderNoTexAdditiveNoZWriteAWrite{})};
|
||||||
}
|
}
|
||||||
|
|
||||||
void CParticleSwooshShaders::Shutdown() {
|
void CParticleSwooshShaders::Shutdown() {
|
||||||
for (auto& s : m_texZWrite)
|
// for (auto& s : m_texZWrite)
|
||||||
s.reset();
|
// s.reset();
|
||||||
for (auto& s : m_texNoZWrite)
|
// for (auto& s : m_texNoZWrite)
|
||||||
s.reset();
|
// s.reset();
|
||||||
for (auto& s : m_texAdditiveZWrite)
|
// for (auto& s : m_texAdditiveZWrite)
|
||||||
s.reset();
|
// s.reset();
|
||||||
for (auto& s : m_texAdditiveNoZWrite)
|
// for (auto& s : m_texAdditiveNoZWrite)
|
||||||
s.reset();
|
// s.reset();
|
||||||
for (auto& s : m_noTexZWrite)
|
// for (auto& s : m_noTexZWrite)
|
||||||
s.reset();
|
// s.reset();
|
||||||
for (auto& s : m_noTexNoZWrite)
|
// for (auto& s : m_noTexNoZWrite)
|
||||||
s.reset();
|
// s.reset();
|
||||||
for (auto& s : m_noTexAdditiveZWrite)
|
// for (auto& s : m_noTexAdditiveZWrite)
|
||||||
s.reset();
|
// s.reset();
|
||||||
for (auto& s : m_noTexAdditiveNoZWrite)
|
// for (auto& s : m_noTexAdditiveNoZWrite)
|
||||||
s.reset();
|
// s.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
CParticleSwooshShaders::EShaderClass CParticleSwooshShaders::GetShaderClass(CParticleSwoosh& gen) {
|
CParticleSwooshShaders::EShaderClass CParticleSwooshShaders::GetShaderClass(CParticleSwoosh& gen) {
|
||||||
|
@ -66,47 +66,47 @@ CParticleSwooshShaders::EShaderClass CParticleSwooshShaders::GetShaderClass(CPar
|
||||||
return EShaderClass::NoTex;
|
return EShaderClass::NoTex;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CParticleSwooshShaders::BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, CParticleSwoosh& gen) {
|
void CParticleSwooshShaders::BuildShaderDataBinding(CParticleSwoosh& gen) {
|
||||||
CSwooshDescription* desc = gen.GetDesc();
|
CSwooshDescription* desc = gen.GetDesc();
|
||||||
std::array<boo::ObjToken<boo::IShaderPipeline>, 2>* pipeline = nullptr;
|
// std::array<boo::ObjToken<boo::IShaderPipeline>, 2>* pipeline = nullptr;
|
||||||
|
//
|
||||||
if (desc->x3c_TEXR) {
|
// if (desc->x3c_TEXR) {
|
||||||
if (desc->x44_31_AALP) {
|
// if (desc->x44_31_AALP) {
|
||||||
if (desc->x45_24_ZBUF)
|
// if (desc->x45_24_ZBUF)
|
||||||
pipeline = &m_texAdditiveZWrite;
|
// pipeline = &m_texAdditiveZWrite;
|
||||||
else
|
// else
|
||||||
pipeline = &m_texAdditiveNoZWrite;
|
// pipeline = &m_texAdditiveNoZWrite;
|
||||||
} else {
|
// } else {
|
||||||
if (desc->x45_24_ZBUF)
|
// if (desc->x45_24_ZBUF)
|
||||||
pipeline = &m_texZWrite;
|
// pipeline = &m_texZWrite;
|
||||||
else
|
// else
|
||||||
pipeline = &m_texNoZWrite;
|
// pipeline = &m_texNoZWrite;
|
||||||
}
|
// }
|
||||||
} else {
|
// } else {
|
||||||
if (desc->x44_31_AALP) {
|
// if (desc->x44_31_AALP) {
|
||||||
if (desc->x45_24_ZBUF)
|
// if (desc->x45_24_ZBUF)
|
||||||
pipeline = &m_noTexAdditiveZWrite;
|
// pipeline = &m_noTexAdditiveZWrite;
|
||||||
else
|
// else
|
||||||
pipeline = &m_noTexAdditiveNoZWrite;
|
// pipeline = &m_noTexAdditiveNoZWrite;
|
||||||
} else {
|
// } else {
|
||||||
if (desc->x45_24_ZBUF)
|
// if (desc->x45_24_ZBUF)
|
||||||
pipeline = &m_noTexZWrite;
|
// pipeline = &m_noTexZWrite;
|
||||||
else
|
// else
|
||||||
pipeline = &m_noTexNoZWrite;
|
// pipeline = &m_noTexNoZWrite;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
const CUVElement* const texr = desc->x3c_TEXR.get();
|
// const CUVElement* const texr = desc->x3c_TEXR.get();
|
||||||
const std::array<boo::ObjToken<boo::ITexture>, 1> textures{
|
// const std::array<boo::ObjToken<boo::ITexture>, 1> textures{
|
||||||
texr ? texr->GetValueTexture(0).GetObj()->GetBooTexture() : nullptr,
|
// texr ? texr->GetValueTexture(0).GetObj()->GetBooTexture() : nullptr,
|
||||||
};
|
// };
|
||||||
|
//
|
||||||
const std::array<boo::ObjToken<boo::IGraphicsBuffer>, 1> uniforms{gen.m_uniformBuf.get()};
|
// const std::array<boo::ObjToken<boo::IGraphicsBuffer>, 1> uniforms{gen.m_uniformBuf.get()};
|
||||||
for (size_t i = 0; i < gen.m_dataBind.size(); ++i) {
|
// for (size_t i = 0; i < gen.m_dataBind.size(); ++i) {
|
||||||
gen.m_dataBind[i] =
|
// gen.m_dataBind[i] =
|
||||||
ctx.newShaderDataBinding((*pipeline)[i], gen.m_vertBuf.get(), nullptr, nullptr, uniforms.size(),
|
// ctx.newShaderDataBinding((*pipeline)[i], gen.m_vertBuf.get(), nullptr, nullptr, uniforms.size(),
|
||||||
uniforms.data(), nullptr, texr ? 1 : 0, textures.data(), nullptr, nullptr);
|
// uniforms.data(), nullptr, texr ? 1 : 0, textures.data(), nullptr, nullptr);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace metaforce
|
} // namespace metaforce
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue