mirror of https://github.com/AxioDL/metaforce.git
Huge shader refactor
This commit is contained in:
parent
0a0a581f2d
commit
c307e354ca
|
@ -14,6 +14,10 @@
|
|||
<mapping directory="$PROJECT_DIR$/hecl/extern/athena" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/hecl/extern/boo" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/hecl/extern/boo/glslang" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/hecl/extern/boo/lib/graphicsdev/NX/libdrm_nouveau" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/hecl/extern/boo/lib/graphicsdev/NX/mesa" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/hecl/extern/boo/lib/graphicsdev/nx/libdrm_nouveau" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/hecl/extern/boo/lib/graphicsdev/nx/mesa" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/hecl/extern/boo/logvisor" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/hecl/extern/libSquish" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/hecl/extern/libjpeg-turbo" vcs="Git" />
|
||||
|
|
|
@ -9,14 +9,17 @@ if(APPLE AND NOT CMAKE_OSX_SYSROOT)
|
|||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
endif()
|
||||
|
||||
project(urde)
|
||||
|
||||
option(URDE_CROSSCOMPILING "Don't build tools; attempt package import" Off)
|
||||
option(URDE_CROSSCOMPILING "Don't build tools; attempt package import" OFF)
|
||||
if (URDE_CROSSCOMPILING)
|
||||
set(CMAKE_CROSSCOMPILING On)
|
||||
set(HAVE_WORDS_BIGENDIAN_EXITCODE 0)
|
||||
endif()
|
||||
|
||||
if(CMAKE_CROSSCOMPILING)
|
||||
set(HAVE_WORDS_BIGENDIAN_EXITCODE 0 CACHE INTEGER "Makes soxr happy" FORCE)
|
||||
endif()
|
||||
|
||||
project(urde)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Force shared libs off" FORCE)
|
||||
|
@ -30,7 +33,11 @@ if(NOT MSVC OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC")
|
|||
include(cotire)
|
||||
endif()
|
||||
|
||||
set(URDE_VECTOR_ISA "sse2" CACHE STRING "Vector ISA to build for (sse2, sse3, sse41, avx, avx2)")
|
||||
if (NX)
|
||||
set(URDE_VECTOR_ISA "neon")
|
||||
else()
|
||||
set(URDE_VECTOR_ISA "sse2" CACHE STRING "Vector ISA to build for (sse2, sse3, sse41, avx, avx2)")
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
if(${URDE_VECTOR_ISA} STREQUAL "avx2")
|
||||
|
@ -99,12 +106,14 @@ else()
|
|||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse2")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse2")
|
||||
message(STATUS "Building with SSE2 Vector ISA")
|
||||
elseif(${URDE_VECTOR_ISA} STREQUAL "neon")
|
||||
message(STATUS "Building with NEON Vector ISA")
|
||||
else()
|
||||
message(STATUS "Building with x87 Vector ISA")
|
||||
endif()
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}\
|
||||
-Wno-multichar -fno-exceptions -Wno-narrowing -Wno-nullability-completeness -Werror=return-type")
|
||||
-Wno-multichar -fno-exceptions -fno-rtti -Wno-narrowing -Wno-nullability-completeness -Werror=return-type")
|
||||
|
||||
if(APPLE)
|
||||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -flto=thin")
|
||||
|
@ -141,13 +150,15 @@ if(USE_LD_GOLD AND ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_
|
|||
endif()
|
||||
|
||||
# Add discord-rpc here
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/rapidjson/include)
|
||||
set(PROJECT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/discord-rpc)
|
||||
if (NOT CMAKE_INSTALL_LIBDIR)
|
||||
set(CMAKE_INSTALL_LIBDIR ${CMAKE_BINARY_DIR}/fake-prefix)
|
||||
if(NOT GEKKO AND NOT NX)
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/rapidjson/include)
|
||||
set(PROJECT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/discord-rpc)
|
||||
if (NOT CMAKE_INSTALL_LIBDIR)
|
||||
set(CMAKE_INSTALL_LIBDIR ${CMAKE_BINARY_DIR}/fake-prefix)
|
||||
endif()
|
||||
add_subdirectory(discord-rpc/src)
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/discord-rpc/include)
|
||||
endif()
|
||||
add_subdirectory(discord-rpc/src)
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/discord-rpc/include)
|
||||
|
||||
add_subdirectory(nod)
|
||||
set(NOD_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/nod/include)
|
||||
|
@ -185,6 +196,10 @@ set(HECL_DATASPEC_PUSHES
|
|||
hecl::Database::DATA_SPEC_REGISTRY.push_back(&DataSpec::SpecEntMP3);
|
||||
hecl::Database::DATA_SPEC_REGISTRY.push_back(&DataSpec::SpecEntMP3PC);
|
||||
hecl::Database::DATA_SPEC_REGISTRY.push_back(&DataSpec::SpecEntMP3ORIG);")
|
||||
add_subdirectory(hecl/shaderc)
|
||||
include(hecl/ApplicationTools.cmake)
|
||||
add_subdirectory(specter/shaders)
|
||||
add_subdirectory(Shaders)
|
||||
add_subdirectory(hecl)
|
||||
|
||||
if(NOT TARGET bintoc)
|
||||
|
@ -233,12 +248,14 @@ add_subdirectory(visigen)
|
|||
|
||||
add_dependencies(hecl visigen)
|
||||
|
||||
find_package(Qt5Widgets)
|
||||
if (Qt5Widgets_FOUND)
|
||||
if (NOT WINDOWS_STORE AND NOT NX)
|
||||
find_package(Qt5Widgets)
|
||||
if (Qt5Widgets_FOUND)
|
||||
message(STATUS "Qt5 found, hecl-gui will be built")
|
||||
add_subdirectory(hecl-gui)
|
||||
else()
|
||||
else()
|
||||
message(STATUS "Qt5 not found, hecl-gui will not be built")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
unset(GIT_EXECUTABLE CACHE)
|
||||
|
|
|
@ -156,7 +156,7 @@ void MaterialSet::ConstructMaterial(Stream& out,
|
|||
for (const Material::SectionFactory& factory : material.sections)
|
||||
{
|
||||
factory.section->constructNode(out, pakRouter, entry, prevSection, i++, texMapIdx, texMtxIdx, kColorIdx);
|
||||
Material::SectionPASS* pass = dynamic_cast<Material::SectionPASS*>(factory.section.get());
|
||||
Material::SectionPASS* pass = Material::SectionPASS::castTo(factory.section.get());
|
||||
if (!pass || (pass && Material::SectionPASS::Subtype(pass->subtype.toUint32()) != Material::SectionPASS::Subtype::RFLV))
|
||||
prevSection = factory.section.get();
|
||||
}
|
||||
|
|
|
@ -74,6 +74,8 @@ struct MaterialSet : BigDNA
|
|||
struct SectionPASS : ISection
|
||||
{
|
||||
SectionPASS() : ISection(ISection::Type::PASS) {}
|
||||
static SectionPASS* castTo(ISection* sec)
|
||||
{ return sec->m_type == Type::PASS ? static_cast<SectionPASS*>(sec) : nullptr; }
|
||||
AT_DECL_DNA
|
||||
AT_DECL_DNAV
|
||||
Value<atUint32> size;
|
||||
|
@ -126,6 +128,8 @@ struct MaterialSet : BigDNA
|
|||
struct SectionCLR : ISection
|
||||
{
|
||||
SectionCLR() : ISection(ISection::Type::CLR) {}
|
||||
static SectionCLR* castTo(ISection* sec)
|
||||
{ return sec->m_type == Type::CLR ? static_cast<SectionCLR*>(sec) : nullptr; }
|
||||
AT_DECL_DNA
|
||||
AT_DECL_DNAV
|
||||
enum class Subtype : atUint32
|
||||
|
@ -148,6 +152,8 @@ struct MaterialSet : BigDNA
|
|||
struct SectionINT : ISection
|
||||
{
|
||||
SectionINT() : ISection(ISection::Type::INT) {}
|
||||
static SectionINT* castTo(ISection* sec)
|
||||
{ return sec->m_type == Type::INT ? static_cast<SectionINT*>(sec) : nullptr; }
|
||||
AT_DECL_DNA
|
||||
AT_DECL_DNAV
|
||||
enum class Subtype : atUint32
|
||||
|
|
|
@ -101,7 +101,9 @@ target_link_libraries(urde
|
|||
UrdeIcons
|
||||
UrdeBadging
|
||||
RuntimeCommon NESEmulator
|
||||
specter specter-fonts freetype ${DATA_SPEC_LIBS}
|
||||
specter specter-fonts
|
||||
${HECL_APPLICATION_REPS_TARGETS_LIST}
|
||||
freetype ${DATA_SPEC_LIBS}
|
||||
hecl-full hecl-blender-addon
|
||||
athena-core nod logvisor athena-libyaml amuse boo
|
||||
${PNG_LIB} libjpeg-turbo squish xxhash zeus
|
||||
|
|
|
@ -98,7 +98,7 @@ void SplitSpace::joinViews(specter::SplitView* thisSplit, int thisSlot, specter:
|
|||
{
|
||||
if (thisSplit == otherSplit)
|
||||
{
|
||||
SplitSpace* thisSS = dynamic_cast<SplitSpace*>(m_slots[thisSlot].get());
|
||||
SplitSpace* thisSS = m_slots[thisSlot]->castToSplitSpace();
|
||||
if (thisSS)
|
||||
{
|
||||
int ax = thisSS->m_state.axis == specter::SplitView::Axis::Horizontal ? 1 : 0;
|
||||
|
@ -115,7 +115,7 @@ void SplitSpace::joinViews(specter::SplitView* thisSplit, int thisSlot, specter:
|
|||
{
|
||||
for (int i=0 ; i<2 ; ++i)
|
||||
{
|
||||
SplitSpace* otherSS = dynamic_cast<SplitSpace*>(m_slots[i].get());
|
||||
SplitSpace* otherSS = m_slots[i]->castToSplitSpace();
|
||||
if (otherSS && otherSS->m_splitView.get() == otherSplit)
|
||||
{
|
||||
int ax = m_state.axis == specter::SplitView::Axis::Horizontal ? 1 : 0;
|
||||
|
@ -248,23 +248,23 @@ void Space::SpaceMenuNode::SubNode::activated(const boo::SWindowCoord &coord)
|
|||
switch(m_data.m_cls)
|
||||
{
|
||||
case Class::InformationCenter:
|
||||
if (typeid(InformationCenter) != typeid(m_space))
|
||||
if (m_space.cls() == Class::InformationCenter)
|
||||
newSpace.reset(new InformationCenter(m_space.m_parent->m_vm, m_space.m_parent));
|
||||
break;
|
||||
case Class::EffectEditor:
|
||||
if (typeid(EffectEditor) != typeid(m_space))
|
||||
if (m_space.cls() == Class::EffectEditor)
|
||||
newSpace.reset(new EffectEditor(m_space.m_parent->m_vm, m_space.m_parent));
|
||||
break;
|
||||
case Class::ResourceBrowser:
|
||||
if (typeid(ResourceBrowser) != typeid(m_space))
|
||||
if (m_space.cls() == Class::ResourceBrowser)
|
||||
newSpace.reset(new ResourceBrowser(m_space.m_parent->m_vm, m_space.m_parent));
|
||||
break;
|
||||
case Class::ModelViewer:
|
||||
if (typeid(ModelViewer) != typeid(m_space))
|
||||
if (m_space.cls() == Class::ModelViewer)
|
||||
newSpace.reset(new ModelViewer(m_space.m_parent->m_vm, m_space.m_parent));
|
||||
break;
|
||||
case Class::GameMode:
|
||||
if (typeid(GameMode) != typeid(m_space))
|
||||
if (m_space.cls() == Class::GameMode)
|
||||
newSpace.reset(new GameMode(m_space.m_parent->m_vm, m_space.m_parent));
|
||||
break;
|
||||
default: break;
|
||||
|
|
|
@ -22,6 +22,7 @@ namespace urde
|
|||
{
|
||||
class ViewManager;
|
||||
class RootSpace;
|
||||
class SplitSpace;
|
||||
|
||||
class Space : public specter::ISpaceController
|
||||
{
|
||||
|
@ -160,6 +161,8 @@ public:
|
|||
{return std::unique_ptr<Space>();}
|
||||
|
||||
virtual specter::View* basisView() {return m_spaceView.get();}
|
||||
Class cls() const { return m_class; }
|
||||
SplitSpace* castToSplitSpace();
|
||||
};
|
||||
|
||||
class RootSpace : public Space
|
||||
|
@ -359,6 +362,8 @@ public:
|
|||
|
||||
specter::View* basisView() {return m_splitView.get();}
|
||||
};
|
||||
inline SplitSpace* Space::castToSplitSpace()
|
||||
{ return cls() == Class::SplitSpace ? static_cast<SplitSpace*>(this) : nullptr; }
|
||||
|
||||
class ViewerSpace : public Space
|
||||
{
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "Audio/CStreamAudioManager.hpp"
|
||||
#include "Runtime/CStateManager.hpp"
|
||||
#include "Runtime/World/CPlayer.hpp"
|
||||
#include "hecl/Pipeline.hpp"
|
||||
#include <cstdio>
|
||||
|
||||
using YAMLNode = athena::io::YAMLNode;
|
||||
|
@ -292,6 +293,8 @@ void ViewManager::init(boo::IApplication* app)
|
|||
float pixelFactor = m_mainWindow->getVirtualPixelFactor();
|
||||
|
||||
m_mainBooFactory = m_mainWindow->getMainContextDataFactory();
|
||||
m_pipelineConv = hecl::NewPipelineConverter(m_mainBooFactory);
|
||||
hecl::conv = m_pipelineConv.get();
|
||||
m_mainPlatformName = m_mainBooFactory->platformName();
|
||||
m_mainWindow->setTitle(_S("URDE [") + hecl::SystemString(m_mainPlatformName) + _S("]"));
|
||||
m_mainCommandQueue = m_mainWindow->getCommandQueue();
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
#include "Runtime/Graphics/Shaders/CCameraBlurFilter.hpp"
|
||||
#include "Runtime/Audio/CStaticAudioPlayer.hpp"
|
||||
|
||||
namespace hecl { class PipelineConverterBase; }
|
||||
|
||||
namespace urde
|
||||
{
|
||||
class SplashScreen;
|
||||
|
@ -43,6 +45,7 @@ class ViewManager final : public specter::IViewManager
|
|||
specter::Translator m_translator;
|
||||
boo::IGraphicsDataFactory* m_mainBooFactory = nullptr;
|
||||
boo::IGraphicsCommandQueue* m_mainCommandQueue = nullptr;
|
||||
std::unique_ptr<hecl::PipelineConverterBase> m_pipelineConv;
|
||||
boo::ObjToken<boo::ITextureR> m_renderTex;
|
||||
const boo::SystemChar* m_mainPlatformName;
|
||||
|
||||
|
|
|
@ -1,334 +1,32 @@
|
|||
#include "CNESShader.hpp"
|
||||
#include "Graphics/CGraphics.hpp"
|
||||
#include "hecl/Pipeline.hpp"
|
||||
|
||||
namespace urde::MP1
|
||||
{
|
||||
|
||||
boo::ObjToken<boo::IShaderPipeline> CNESShader::g_Pipeline;
|
||||
boo::ObjToken<boo::IVertexFormat> CNESShader::g_VtxFmt;
|
||||
|
||||
static const char* VS_GLSL =
|
||||
"#version 330\n"
|
||||
BOO_GLSL_BINDING_HEAD
|
||||
"layout(location=0) in vec4 posIn;\n"
|
||||
"layout(location=1) in vec4 uvIn;\n"
|
||||
"\n"
|
||||
"UBINDING0 uniform TexuredQuadUniform\n"
|
||||
"{\n"
|
||||
" mat4 mtx;\n"
|
||||
" vec4 color;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" vec4 color;\n"
|
||||
" vec2 uv;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"SBINDING(0) out VertToFrag vtf;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" vtf.color = color;\n"
|
||||
" vtf.uv = uvIn.xy;\n"
|
||||
" gl_Position = mtx * vec4(posIn.xyz, 1.0);\n"
|
||||
" gl_Position = FLIPFROMGL(gl_Position);\n"
|
||||
"}\n";
|
||||
|
||||
static const char* FS_GLSL =
|
||||
"#version 330\n"
|
||||
BOO_GLSL_BINDING_HEAD
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" vec4 color;\n"
|
||||
" vec2 uv;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"SBINDING(0) in VertToFrag vtf;\n"
|
||||
"layout(location=0) out vec4 colorOut;\n"
|
||||
"TBINDING0 uniform sampler2D tex;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" colorOut = vtf.color * texture(tex, vtf.uv);\n"
|
||||
"}\n";
|
||||
|
||||
#if _WIN32
|
||||
static const char* VS_HLSL =
|
||||
"struct VertData\n"
|
||||
"{\n"
|
||||
" float4 posIn : POSITION;\n"
|
||||
" float4 uvIn : UV;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"cbuffer TexuredQuadUniform : register(b0)\n"
|
||||
"{\n"
|
||||
" float4x4 mat;\n"
|
||||
" float4 color;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 position : SV_Position;\n"
|
||||
" float4 color : COLOR;\n"
|
||||
" float2 uv : UV;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"VertToFrag main(in VertData v)\n"
|
||||
"{\n"
|
||||
" VertToFrag vtf;\n"
|
||||
" vtf.color = color;\n"
|
||||
" vtf.uv = v.uvIn.xy;\n"
|
||||
" vtf.position = mul(mat, float4(v.posIn.xyz, 1.0));\n"
|
||||
" return vtf;\n"
|
||||
"}\n";
|
||||
|
||||
static const char* FS_HLSL =
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 position : SV_Position;\n"
|
||||
" float4 color : COLOR;\n"
|
||||
" float2 uv : UV;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"Texture2D tex : register(t0);\n"
|
||||
"SamplerState samp : register(s4);\n"
|
||||
"\n"
|
||||
"float4 main(in VertToFrag vtf) : SV_Target0\n"
|
||||
"{\n"
|
||||
" return vtf.color * tex.Sample(samp, vtf.uv);\n"
|
||||
"}\n";
|
||||
#endif
|
||||
|
||||
#if BOO_HAS_METAL
|
||||
static const char* VS_METAL =
|
||||
"#include <metal_stdlib>\n"
|
||||
"using namespace metal;\n"
|
||||
"struct VertData\n"
|
||||
"{\n"
|
||||
" float4 posIn [[ attribute(0) ]];\n"
|
||||
" float4 uvIn [[ attribute(1) ]];\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct TexuredQuadUniform\n"
|
||||
"{\n"
|
||||
" float4x4 mat;\n"
|
||||
" float4 color;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 position [[ position ]];\n"
|
||||
" float4 color;\n"
|
||||
" float2 uv;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"vertex VertToFrag vmain(VertData v [[ stage_in ]], constant TexuredQuadUniform& tqu [[ buffer(2) ]])\n"
|
||||
"{\n"
|
||||
" VertToFrag vtf;\n"
|
||||
" vtf.color = tqu.color;\n"
|
||||
" vtf.uv = v.uvIn.xy;\n"
|
||||
" vtf.position = tqu.mat * float4(v.posIn.xyz, 1.0);\n"
|
||||
" return vtf;\n"
|
||||
"}\n";
|
||||
|
||||
|
||||
static const char* FS_METAL =
|
||||
"#include <metal_stdlib>\n"
|
||||
"using namespace metal;\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 position [[ position ]];\n"
|
||||
" float4 color;\n"
|
||||
" float2 uv;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"fragment float4 fmain(VertToFrag vtf [[ stage_in ]],\n"
|
||||
" sampler clampSamp [[ sampler(4) ]],\n"
|
||||
" texture2d<float> tex [[ texture(0) ]])\n"
|
||||
"{\n"
|
||||
" return vtf.color * tex.sample(clampSamp, vtf.uv);\n"
|
||||
"}\n";
|
||||
#endif
|
||||
|
||||
#if BOO_HAS_GL
|
||||
void CNESShader::Initialize(boo::GLDataFactory::Context& ctx)
|
||||
void CNESShader::Initialize()
|
||||
{
|
||||
const char* texNames[] = {"tex"};
|
||||
const char* uniNames[] = {"TexuredQuadUniform"};
|
||||
g_Pipeline = ctx.newShaderPipeline(VS_GLSL, FS_GLSL, 1, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha,
|
||||
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
|
||||
boo::ZTest::None, false, true, false, boo::CullMode::None);
|
||||
g_Pipeline = hecl::conv->convert(Shader_CNESShader{});
|
||||
}
|
||||
|
||||
boo::ObjToken<boo::IShaderDataBinding> CNESShader::BuildShaderDataBinding(boo::GLDataFactory::Context& ctx,
|
||||
boo::ObjToken<boo::IGraphicsBufferS> vbo,
|
||||
boo::ObjToken<boo::IGraphicsBufferD> uniBuf,
|
||||
boo::ObjToken<boo::ITextureD> tex)
|
||||
{
|
||||
const boo::VertexElementDescriptor VtxVmt[] =
|
||||
{
|
||||
{vbo.get(), nullptr, boo::VertexSemantic::Position4},
|
||||
{vbo.get(), nullptr, boo::VertexSemantic::UV4}
|
||||
};
|
||||
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,
|
||||
ctx.newVertexFormat(2, VtxVmt), vbo.get(), nullptr, nullptr,
|
||||
1, bufs, stages, nullptr, nullptr, 1, texs, nullptr, nullptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if _WIN32
|
||||
void CNESShader::Initialize(boo::D3DDataFactory::Context& ctx)
|
||||
{
|
||||
const boo::VertexElementDescriptor VtxVmt[] =
|
||||
{
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4},
|
||||
{nullptr, nullptr, boo::VertexSemantic::UV4}
|
||||
};
|
||||
g_VtxFmt = ctx.newVertexFormat(2, VtxVmt);
|
||||
g_Pipeline = ctx.newShaderPipeline(VS_HLSL, FS_HLSL, nullptr, nullptr, nullptr,
|
||||
g_VtxFmt, boo::BlendFactor::SrcAlpha,
|
||||
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
|
||||
boo::ZTest::None, false, true, false, boo::CullMode::None);
|
||||
}
|
||||
|
||||
boo::ObjToken<boo::IShaderDataBinding> CNESShader::BuildShaderDataBinding(boo::D3DDataFactory::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::ObjToken<boo::ITexture> texs[] = {tex.get()};
|
||||
return ctx.newShaderDataBinding(g_Pipeline, g_VtxFmt,
|
||||
vbo.get(), nullptr, nullptr, 1, bufs,
|
||||
nullptr, nullptr, nullptr, 1, texs, nullptr, nullptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if BOO_HAS_METAL
|
||||
void CNESShader::Initialize(boo::MetalDataFactory::Context& ctx)
|
||||
{
|
||||
const boo::VertexElementDescriptor VtxVmt[] =
|
||||
{
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4},
|
||||
{nullptr, nullptr, boo::VertexSemantic::UV4}
|
||||
};
|
||||
g_VtxFmt = ctx.newVertexFormat(2, VtxVmt);
|
||||
g_Pipeline = ctx.newShaderPipeline(VS_METAL, FS_METAL, nullptr, nullptr,
|
||||
g_VtxFmt, boo::BlendFactor::SrcAlpha,
|
||||
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
|
||||
boo::ZTest::None, false, true, false, boo::CullMode::None);
|
||||
}
|
||||
|
||||
boo::ObjToken<boo::IShaderDataBinding> CNESShader::BuildShaderDataBinding(boo::MetalDataFactory::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::ObjToken<boo::ITexture> texs[] = {tex.get()};
|
||||
return ctx.newShaderDataBinding(g_Pipeline, g_VtxFmt,
|
||||
vbo.get(), nullptr, nullptr, 1, bufs,
|
||||
nullptr, nullptr, nullptr, 1, texs, nullptr, nullptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if BOO_HAS_VULKAN
|
||||
void CNESShader::Initialize(boo::VulkanDataFactory::Context& ctx)
|
||||
{
|
||||
const boo::VertexElementDescriptor VtxVmt[] =
|
||||
{
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4},
|
||||
{nullptr, nullptr, boo::VertexSemantic::UV4}
|
||||
};
|
||||
g_VtxFmt = ctx.newVertexFormat(2, VtxVmt);
|
||||
g_Pipeline = ctx.newShaderPipeline(VS_GLSL, FS_GLSL, g_VtxFmt, boo::BlendFactor::SrcAlpha,
|
||||
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
|
||||
boo::ZTest::None, false, true, false, boo::CullMode::None);
|
||||
}
|
||||
|
||||
boo::ObjToken<boo::IShaderDataBinding> CNESShader::BuildShaderDataBinding(boo::VulkanDataFactory::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::ObjToken<boo::ITexture> texs[] = {tex.get()};
|
||||
return ctx.newShaderDataBinding(g_Pipeline, g_VtxFmt,
|
||||
vbo.get(), nullptr, nullptr, 1, bufs,
|
||||
nullptr, nullptr, nullptr, 1, texs, nullptr, nullptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
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)
|
||||
{
|
||||
switch (ctx.platform())
|
||||
{
|
||||
#if BOO_HAS_GL
|
||||
case boo::IGraphicsDataFactory::Platform::OpenGL:
|
||||
return BuildShaderDataBinding(static_cast<boo::GLDataFactory::Context&>(ctx), vbo, uniBuf, tex);
|
||||
#endif
|
||||
#if _WIN32
|
||||
case boo::IGraphicsDataFactory::Platform::D3D11:
|
||||
return BuildShaderDataBinding(static_cast<boo::D3DDataFactory::Context&>(ctx), vbo, uniBuf, tex);
|
||||
#endif
|
||||
#if BOO_HAS_METAL
|
||||
case boo::IGraphicsDataFactory::Platform::Metal:
|
||||
return BuildShaderDataBinding(static_cast<boo::MetalDataFactory::Context&>(ctx), vbo, uniBuf, tex);
|
||||
#endif
|
||||
#if BOO_HAS_VULKAN
|
||||
case boo::IGraphicsDataFactory::Platform::Vulkan:
|
||||
return BuildShaderDataBinding(static_cast<boo::VulkanDataFactory::Context&>(ctx), vbo, uniBuf, tex);
|
||||
#endif
|
||||
default:
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
void CNESShader::Initialize()
|
||||
{
|
||||
if (!CGraphics::g_BooFactory)
|
||||
return;
|
||||
|
||||
CGraphics::CommitResources(
|
||||
[&](boo::IGraphicsDataFactory::Context& ctx)
|
||||
{
|
||||
switch (ctx.platform())
|
||||
{
|
||||
#if BOO_HAS_GL
|
||||
case boo::IGraphicsDataFactory::Platform::OpenGL:
|
||||
Initialize(static_cast<boo::GLDataFactory::Context&>(ctx));
|
||||
break;
|
||||
#endif
|
||||
#if _WIN32
|
||||
case boo::IGraphicsDataFactory::Platform::D3D11:
|
||||
Initialize(static_cast<boo::D3DDataFactory::Context&>(ctx));
|
||||
break;
|
||||
#endif
|
||||
#if BOO_HAS_METAL
|
||||
case boo::IGraphicsDataFactory::Platform::Metal:
|
||||
Initialize(static_cast<boo::MetalDataFactory::Context&>(ctx));
|
||||
break;
|
||||
#endif
|
||||
#if BOO_HAS_VULKAN
|
||||
case boo::IGraphicsDataFactory::Platform::Vulkan:
|
||||
Initialize(static_cast<boo::VulkanDataFactory::Context&>(ctx));
|
||||
break;
|
||||
#endif
|
||||
default: break;
|
||||
}
|
||||
return true;
|
||||
} BooTrace);
|
||||
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();
|
||||
g_VtxFmt.reset();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
#ifndef URDE_CNESSHADER_HPP
|
||||
#define URDE_CNESSHADER_HPP
|
||||
|
||||
#include "boo/graphicsdev/GL.hpp"
|
||||
#include "boo/graphicsdev/Metal.hpp"
|
||||
#include "boo/graphicsdev/D3D.hpp"
|
||||
#include "boo/graphicsdev/Vulkan.hpp"
|
||||
#include "boo/graphicsdev/IGraphicsDataFactory.hpp"
|
||||
|
||||
namespace urde::MP1
|
||||
{
|
||||
|
@ -12,34 +9,6 @@ namespace urde::MP1
|
|||
class CNESShader
|
||||
{
|
||||
public:
|
||||
#if BOO_HAS_GL
|
||||
static void Initialize(boo::GLDataFactory::Context& ctx);
|
||||
static boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::GLDataFactory::Context& ctx,
|
||||
boo::ObjToken<boo::IGraphicsBufferS> vbo,
|
||||
boo::ObjToken<boo::IGraphicsBufferD> uniBuf,
|
||||
boo::ObjToken<boo::ITextureD> tex);
|
||||
#endif
|
||||
#if _WIN32
|
||||
static void Initialize(boo::D3DDataFactory::Context& ctx);
|
||||
static boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::D3DDataFactory::Context& ctx,
|
||||
boo::ObjToken<boo::IGraphicsBufferS> vbo,
|
||||
boo::ObjToken<boo::IGraphicsBufferD> uniBuf,
|
||||
boo::ObjToken<boo::ITextureD> tex);
|
||||
#endif
|
||||
#if BOO_HAS_METAL
|
||||
static void Initialize(boo::MetalDataFactory::Context& ctx);
|
||||
static boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::MetalDataFactory::Context& ctx,
|
||||
boo::ObjToken<boo::IGraphicsBufferS> vbo,
|
||||
boo::ObjToken<boo::IGraphicsBufferD> uniBuf,
|
||||
boo::ObjToken<boo::ITextureD> tex);
|
||||
#endif
|
||||
#if BOO_HAS_VULKAN
|
||||
static void Initialize(boo::VulkanDataFactory::Context& ctx);
|
||||
static boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::VulkanDataFactory::Context& ctx,
|
||||
boo::ObjToken<boo::IGraphicsBufferS> vbo,
|
||||
boo::ObjToken<boo::IGraphicsBufferD> uniBuf,
|
||||
boo::ObjToken<boo::ITextureD> tex);
|
||||
#endif
|
||||
static void Initialize();
|
||||
static void Shutdown();
|
||||
|
||||
|
@ -49,7 +18,6 @@ public:
|
|||
boo::ObjToken<boo::ITextureD> tex);
|
||||
|
||||
static boo::ObjToken<boo::IShaderPipeline> g_Pipeline;
|
||||
static boo::ObjToken<boo::IVertexFormat> g_VtxFmt;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -104,7 +104,7 @@ public:
|
|||
template <class T>
|
||||
const T* GetParm() const
|
||||
{
|
||||
return dynamic_cast<T*>(x8_parm.get());
|
||||
return static_cast<T*>(x8_parm.get());
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -1,85 +1,3 @@
|
|||
if(WIN32)
|
||||
set(PLAT_SRCS
|
||||
Shaders/CLineRendererShadersHLSL.cpp
|
||||
Shaders/CTexturedQuadFilterHLSL.cpp
|
||||
Shaders/CColoredQuadFilterHLSL.cpp
|
||||
Shaders/CModelShadersHLSL.cpp
|
||||
Shaders/CThermalColdFilterHLSL.cpp
|
||||
Shaders/CThermalHotFilterHLSL.cpp
|
||||
Shaders/CSpaceWarpFilterHLSL.cpp
|
||||
Shaders/CCameraBlurFilterHLSL.cpp
|
||||
Shaders/CXRayBlurFilterHLSL.cpp
|
||||
Shaders/CTextSupportShaderHLSL.cpp
|
||||
Shaders/CFogVolumePlaneShaderHLSL.cpp
|
||||
Shaders/CFogVolumeFilterHLSL.cpp
|
||||
Shaders/CEnergyBarShaderHLSL.cpp
|
||||
Shaders/CRadarPaintShaderHLSL.cpp
|
||||
Shaders/CMapSurfaceShaderHLSL.cpp
|
||||
Shaders/CPhazonSuitFilterHLSL.cpp
|
||||
Shaders/CScanLinesFilterHLSL.cpp
|
||||
Shaders/CRandomStaticFilterHLSL.cpp
|
||||
Shaders/CElementGenShadersHLSL.cpp
|
||||
Shaders/CDecalShadersHLSL.cpp
|
||||
Shaders/CParticleSwooshShadersHLSL.cpp
|
||||
Shaders/CFluidPlaneShaderHLSL.cpp
|
||||
Shaders/CAABoxShaderHLSL.cpp
|
||||
Shaders/CWorldShadowShaderHLSL.cpp)
|
||||
elseif(BOO_HAS_METAL)
|
||||
set(PLAT_SRCS
|
||||
Shaders/CLineRendererShadersMetal.cpp
|
||||
Shaders/CTexturedQuadFilterMetal.cpp
|
||||
Shaders/CColoredQuadFilterMetal.cpp
|
||||
Shaders/CModelShadersMetal.cpp
|
||||
Shaders/CThermalColdFilterMetal.cpp
|
||||
Shaders/CThermalHotFilterMetal.cpp
|
||||
Shaders/CSpaceWarpFilterMetal.cpp
|
||||
Shaders/CCameraBlurFilterMetal.cpp
|
||||
Shaders/CXRayBlurFilterMetal.cpp
|
||||
Shaders/CTextSupportShaderMetal.cpp
|
||||
Shaders/CFogVolumePlaneShaderMetal.cpp
|
||||
Shaders/CFogVolumeFilterMetal.cpp
|
||||
Shaders/CEnergyBarShaderMetal.cpp
|
||||
Shaders/CRadarPaintShaderMetal.cpp
|
||||
Shaders/CMapSurfaceShaderMetal.cpp
|
||||
Shaders/CPhazonSuitFilterMetal.cpp
|
||||
Shaders/CScanLinesFilterMetal.cpp
|
||||
Shaders/CRandomStaticFilterMetal.cpp
|
||||
Shaders/CElementGenShadersMetal.cpp
|
||||
Shaders/CDecalShadersMetal.cpp
|
||||
Shaders/CParticleSwooshShadersMetal.cpp
|
||||
Shaders/CFluidPlaneShaderMetal.cpp
|
||||
Shaders/CAABoxShaderMetal.cpp
|
||||
Shaders/CWorldShadowShaderMetal.cpp)
|
||||
endif()
|
||||
|
||||
if(NOT WINDOWS_STORE)
|
||||
list(APPEND PLAT_SRCS
|
||||
Shaders/CLineRendererShadersGLSL.cpp
|
||||
Shaders/CTexturedQuadFilterGLSL.cpp
|
||||
Shaders/CColoredQuadFilterGLSL.cpp
|
||||
Shaders/CModelShadersGLSL.cpp
|
||||
Shaders/CThermalColdFilterGLSL.cpp
|
||||
Shaders/CThermalHotFilterGLSL.cpp
|
||||
Shaders/CSpaceWarpFilterGLSL.cpp
|
||||
Shaders/CCameraBlurFilterGLSL.cpp
|
||||
Shaders/CXRayBlurFilterGLSL.cpp
|
||||
Shaders/CTextSupportShaderGLSL.cpp
|
||||
Shaders/CFogVolumePlaneShaderGLSL.cpp
|
||||
Shaders/CFogVolumeFilterGLSL.cpp
|
||||
Shaders/CEnergyBarShaderGLSL.cpp
|
||||
Shaders/CRadarPaintShaderGLSL.cpp
|
||||
Shaders/CMapSurfaceShaderGLSL.cpp
|
||||
Shaders/CPhazonSuitFilterGLSL.cpp
|
||||
Shaders/CScanLinesFilterGLSL.cpp
|
||||
Shaders/CRandomStaticFilterGLSL.cpp
|
||||
Shaders/CElementGenShadersGLSL.cpp
|
||||
Shaders/CDecalShadersGLSL.cpp
|
||||
Shaders/CParticleSwooshShadersGLSL.cpp
|
||||
Shaders/CFluidPlaneShaderGLSL.cpp
|
||||
Shaders/CAABoxShaderGLSL.cpp
|
||||
Shaders/CWorldShadowShaderGLSL.cpp)
|
||||
endif()
|
||||
|
||||
set(GRAPHICS_SOURCES
|
||||
IRenderer.hpp
|
||||
IWeaponRenderer.hpp IWeaponRenderer.cpp
|
||||
|
@ -101,12 +19,11 @@ set(GRAPHICS_SOURCES
|
|||
CGraphics.hpp CGraphics.cpp
|
||||
CSimpleShadow.hpp CSimpleShadow.cpp
|
||||
CRainSplashGenerator.hpp CRainSplashGenerator.cpp
|
||||
Shaders/TShader.hpp Shaders/TMultiBlendShader.hpp
|
||||
Shaders/TShaderDecl.hpp Shaders/TMultiBlendShaderDecl.hpp
|
||||
Shaders/CLineRendererShaders.hpp Shaders/CLineRendererShaders.cpp
|
||||
Shaders/CTexturedQuadFilter.hpp Shaders/CTexturedQuadFilter.cpp
|
||||
Shaders/CColoredQuadFilter.hpp Shaders/CColoredQuadFilter.cpp
|
||||
Shaders/CModelShaders.hpp Shaders/CModelShaders.cpp
|
||||
Shaders/CModelShadersGLSL.cpp Shaders/CModelShadersHLSL.cpp Shaders/CModelShadersMetal.cpp
|
||||
Shaders/CThermalColdFilter.hpp Shaders/CThermalColdFilter.cpp
|
||||
Shaders/CThermalHotFilter.hpp Shaders/CThermalHotFilter.cpp
|
||||
Shaders/CSpaceWarpFilter.hpp Shaders/CSpaceWarpFilter.cpp
|
||||
|
@ -126,7 +43,6 @@ set(GRAPHICS_SOURCES
|
|||
Shaders/CParticleSwooshShaders.hpp Shaders/CParticleSwooshShaders.cpp
|
||||
Shaders/CFluidPlaneShader.hpp Shaders/CFluidPlaneShader.cpp
|
||||
Shaders/CAABoxShader.hpp Shaders/CAABoxShader.cpp
|
||||
Shaders/CWorldShadowShader.hpp Shaders/CWorldShadowShader.cpp
|
||||
${PLAT_SRCS})
|
||||
Shaders/CWorldShadowShader.hpp Shaders/CWorldShadowShader.cpp)
|
||||
|
||||
runtime_add_list(Graphics GRAPHICS_SOURCES)
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
#include "RetroTypes.hpp"
|
||||
#include "zeus/CTransform.hpp"
|
||||
#include "zeus/CAABox.hpp"
|
||||
#include "hecl/Runtime.hpp"
|
||||
#include "hecl/HMDLMeta.hpp"
|
||||
#include "Shaders/CModelShaders.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
@ -24,7 +24,7 @@ class CMetroidModelInstance
|
|||
std::vector<CBooSurface> m_surfaces;
|
||||
std::unique_ptr<CBooModel> m_instance;
|
||||
hecl::HMDLMeta m_hmdlMeta;
|
||||
std::unordered_map<int, std::shared_ptr<hecl::Runtime::ShaderPipelines>> m_shaders;
|
||||
std::unordered_map<int, CModelShaders::ShaderPipelines> m_shaders;
|
||||
public:
|
||||
CMetroidModelInstance() = default;
|
||||
CMetroidModelInstance(CMetroidModelInstance&&) = default;
|
||||
|
|
|
@ -103,18 +103,20 @@ struct GeometryUniformLayout
|
|||
|
||||
struct SShader
|
||||
{
|
||||
|
||||
|
||||
std::vector<TCachedToken<CTexture>> x0_textures;
|
||||
std::unordered_map<int, std::shared_ptr<hecl::Runtime::ShaderPipelines>> m_shaders;
|
||||
std::unordered_map<int, CModelShaders::ShaderPipelines> m_shaders;
|
||||
MaterialSet m_matSet;
|
||||
std::experimental::optional<GeometryUniformLayout> m_geomLayout;
|
||||
int m_matSetIdx;
|
||||
SShader(int idx) : m_matSetIdx(idx) {}
|
||||
void InitializeLayout(const CModel* model) { m_geomLayout.emplace(model, &m_matSet); }
|
||||
void UnlockTextures();
|
||||
std::shared_ptr<hecl::Runtime::ShaderPipelines>
|
||||
CModelShaders::ShaderPipelines
|
||||
BuildShader(const hecl::HMDLMeta& meta, const MaterialSet::Material& mat);
|
||||
void BuildShaders(const hecl::HMDLMeta& meta,
|
||||
std::unordered_map<int, std::shared_ptr<hecl::Runtime::ShaderPipelines>>& shaders);
|
||||
std::unordered_map<int, CModelShaders::ShaderPipelines>& shaders);
|
||||
void BuildShaders(const hecl::HMDLMeta& meta) { BuildShaders(meta, m_shaders); }
|
||||
};
|
||||
|
||||
|
@ -144,7 +146,7 @@ private:
|
|||
const MaterialSet* x4_matSet;
|
||||
const GeometryUniformLayout* m_geomLayout;
|
||||
int m_matSetIdx = -1;
|
||||
const std::unordered_map<int, std::shared_ptr<hecl::Runtime::ShaderPipelines>>* m_pipelines;
|
||||
const std::unordered_map<int, CModelShaders::ShaderPipelines>* m_pipelines;
|
||||
std::vector<TCachedToken<CTexture>> x1c_textures;
|
||||
zeus::CAABox x20_aabb;
|
||||
CBooSurface* x38_firstUnsortedSurface = nullptr;
|
||||
|
@ -170,15 +172,12 @@ private:
|
|||
boo::ObjToken<boo::IGraphicsBufferD> m_geomUniformBuffer;
|
||||
boo::ObjToken<boo::IGraphicsBufferD> m_uniformBuffer;
|
||||
std::vector<std::vector<boo::ObjToken<boo::IShaderDataBinding>>> m_shaderDataBindings;
|
||||
boo::ObjToken<boo::IVertexFormat> m_dynamicVtxFmt;
|
||||
boo::ObjToken<boo::IGraphicsBufferD> m_dynamicVbo;
|
||||
|
||||
boo::ObjToken<boo::IGraphicsBuffer> GetBooVBO(const CBooModel& model, boo::IGraphicsDataFactory::Context& ctx);
|
||||
boo::ObjToken<boo::IVertexFormat> GetBooVtxFmt(const CBooModel& model, boo::IGraphicsDataFactory::Context& ctx);
|
||||
};
|
||||
std::vector<ModelInstance> m_instances;
|
||||
|
||||
boo::ObjToken<boo::IVertexFormat> m_staticVtxFmt;
|
||||
boo::ObjToken<boo::IGraphicsBufferS> m_staticVbo;
|
||||
boo::ObjToken<boo::IGraphicsBufferS> m_staticIbo;
|
||||
|
||||
|
@ -206,9 +205,8 @@ private:
|
|||
public:
|
||||
~CBooModel();
|
||||
CBooModel(TToken<CModel>& token, CModel* parent, std::vector<CBooSurface>* surfaces, SShader& shader,
|
||||
const boo::ObjToken<boo::IVertexFormat>& vtxFmt, const boo::ObjToken<boo::IGraphicsBufferS>& vbo,
|
||||
const boo::ObjToken<boo::IGraphicsBufferS>& ibo, const zeus::CAABox& aabb, u8 renderMask,
|
||||
int numInsts, const boo::ObjToken<boo::ITexture> txtrOverrides[8]);
|
||||
const boo::ObjToken<boo::IGraphicsBufferS>& vbo, const boo::ObjToken<boo::IGraphicsBufferS>& ibo,
|
||||
const zeus::CAABox& aabb, u8 renderMask, int numInsts, const boo::ObjToken<boo::ITexture> txtrOverrides[8]);
|
||||
|
||||
static void MakeTexturesFromMats(const MaterialSet& matSet,
|
||||
std::vector<TCachedToken<CTexture>>& toksOut,
|
||||
|
@ -221,7 +219,7 @@ public:
|
|||
void DisableAllLights();
|
||||
void RemapMaterialData(SShader& shader);
|
||||
void RemapMaterialData(SShader& shader,
|
||||
const std::unordered_map<int, std::shared_ptr<hecl::Runtime::ShaderPipelines>>& pipelines);
|
||||
const std::unordered_map<int, CModelShaders::ShaderPipelines>& pipelines);
|
||||
bool TryLockTextures() const;
|
||||
void UnlockTextures() const;
|
||||
void SyncLoadTextures() const;
|
||||
|
@ -292,7 +290,6 @@ class CModel
|
|||
int x38_lastFrame;
|
||||
|
||||
/* urde addition: boo! */
|
||||
boo::ObjToken<boo::IVertexFormat> m_staticVtxFmt;
|
||||
boo::ObjToken<boo::IGraphicsBufferS> m_staticVbo;
|
||||
hecl::HMDLMeta m_hmdlMeta;
|
||||
std::unique_ptr<uint8_t[]> m_dynamicVertexData;
|
||||
|
|
|
@ -155,13 +155,12 @@ CBooModel::~CBooModel()
|
|||
}
|
||||
|
||||
CBooModel::CBooModel(TToken<CModel>& token, CModel* parent, std::vector<CBooSurface>* surfaces, SShader& shader,
|
||||
const boo::ObjToken<boo::IVertexFormat>& vtxFmt, const boo::ObjToken<boo::IGraphicsBufferS>& vbo,
|
||||
const boo::ObjToken<boo::IGraphicsBufferS>& ibo, const zeus::CAABox& aabb, u8 renderMask,
|
||||
int numInsts, const boo::ObjToken<boo::ITexture> txtrOverrides[8])
|
||||
const boo::ObjToken<boo::IGraphicsBufferS>& vbo, const boo::ObjToken<boo::IGraphicsBufferS>& ibo,
|
||||
const zeus::CAABox& aabb, u8 renderMask, int numInsts, const boo::ObjToken<boo::ITexture> txtrOverrides[8])
|
||||
: m_modelTok(token), m_model(parent), x0_surfaces(surfaces), x4_matSet(&shader.m_matSet),
|
||||
m_geomLayout(&*shader.m_geomLayout), m_matSetIdx(shader.m_matSetIdx), m_pipelines(&shader.m_shaders),
|
||||
x1c_textures(shader.x0_textures), x20_aabb(aabb), x40_24_texturesLoaded(false), x40_25_modelVisible(0),
|
||||
x41_mask(renderMask), m_staticVtxFmt(vtxFmt), m_staticVbo(vbo), m_staticIbo(ibo)
|
||||
x41_mask(renderMask), m_staticVbo(vbo), m_staticIbo(ibo)
|
||||
{
|
||||
if (txtrOverrides)
|
||||
for (int i=0 ; i<8 ; ++i)
|
||||
|
@ -217,21 +216,6 @@ CBooModel::ModelInstance::GetBooVBO(const CBooModel& model,
|
|||
return m_dynamicVbo.get();
|
||||
}
|
||||
|
||||
boo::ObjToken<boo::IVertexFormat>
|
||||
CBooModel::ModelInstance::GetBooVtxFmt(const CBooModel& model,
|
||||
boo::IGraphicsDataFactory::Context& ctx)
|
||||
{
|
||||
if (model.m_staticVtxFmt)
|
||||
return model.m_staticVtxFmt;
|
||||
if (!m_dynamicVtxFmt && model.m_model)
|
||||
{
|
||||
const CModel& parent = *model.m_model;
|
||||
m_dynamicVtxFmt = hecl::Runtime::HMDLData::NewVertexFormat(ctx, parent.m_hmdlMeta,
|
||||
GetBooVBO(model, ctx), parent.m_ibo.get());
|
||||
}
|
||||
return m_dynamicVtxFmt;
|
||||
}
|
||||
|
||||
GeometryUniformLayout::GeometryUniformLayout(const CModel* model, const MaterialSet* matSet)
|
||||
{
|
||||
if (model)
|
||||
|
@ -418,14 +402,14 @@ CBooModel::ModelInstance* CBooModel::PushNewModelInstance(int sharedLayoutBuf)
|
|||
}
|
||||
thisSizes[3] = 256;
|
||||
|
||||
const std::shared_ptr<hecl::Runtime::ShaderPipelines>& pipelines = m_pipelines->at(surf.m_data.matIdx);
|
||||
const CModelShaders::ShaderPipelines& pipelines = m_pipelines->at(surf.m_data.matIdx);
|
||||
|
||||
newInst.m_shaderDataBindings.emplace_back();
|
||||
std::vector<boo::ObjToken<boo::IShaderDataBinding>>& extendeds = newInst.m_shaderDataBindings.back();
|
||||
extendeds.reserve(pipelines->m_pipelines.size());
|
||||
extendeds.reserve(pipelines->size());
|
||||
|
||||
int idx = 0;
|
||||
for (const boo::ObjToken<boo::IShaderPipeline>& pipeline : pipelines->m_pipelines)
|
||||
for (const auto& pipeline : *pipelines)
|
||||
{
|
||||
boo::ObjToken<boo::ITexture>* ltexs;
|
||||
if (idx == EExtendedShader::Thermal)
|
||||
|
@ -454,7 +438,7 @@ CBooModel::ModelInstance* CBooModel::PushNewModelInstance(int sharedLayoutBuf)
|
|||
ltexs = texs;
|
||||
}
|
||||
extendeds.push_back(
|
||||
ctx.newShaderDataBinding(pipeline, newInst.GetBooVtxFmt(*this, ctx),
|
||||
ctx.newShaderDataBinding(pipeline,
|
||||
newInst.GetBooVBO(*this, ctx), nullptr, m_staticIbo.get(), 4, bufs,
|
||||
stages, thisOffs, thisSizes, 8, ltexs, nullptr, nullptr));
|
||||
++idx;
|
||||
|
@ -513,7 +497,7 @@ void CBooModel::RemapMaterialData(SShader& shader)
|
|||
}
|
||||
|
||||
void CBooModel::RemapMaterialData(SShader& shader,
|
||||
const std::unordered_map<int, std::shared_ptr<hecl::Runtime::ShaderPipelines>>& pipelines)
|
||||
const std::unordered_map<int, CModelShaders::ShaderPipelines>& pipelines)
|
||||
{
|
||||
if (!shader.m_geomLayout)
|
||||
return;
|
||||
|
@ -1204,14 +1188,13 @@ std::unique_ptr<CBooModel> CModel::MakeNewInstance(int shaderIdx, int subInsts,
|
|||
if (shaderIdx >= x18_matSets.size())
|
||||
shaderIdx = 0;
|
||||
auto ret = std::make_unique<CBooModel>(m_selfToken, this, &x8_surfaces, x18_matSets[shaderIdx],
|
||||
m_staticVtxFmt, m_staticVbo, m_ibo,
|
||||
m_aabb, (m_flags & 0x2) != 0, subInsts, txtrOverrides);
|
||||
m_staticVbo, m_ibo, m_aabb, (m_flags & 0x2) != 0, subInsts, txtrOverrides);
|
||||
if (lockParent)
|
||||
ret->LockParent();
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::shared_ptr<hecl::Runtime::ShaderPipelines>
|
||||
CModelShaders::ShaderPipelines
|
||||
SShader::BuildShader(const hecl::HMDLMeta& meta, const MaterialSet::Material& mat)
|
||||
{
|
||||
hecl::Backend::ReflectionType reflectionType;
|
||||
|
@ -1221,16 +1204,15 @@ SShader::BuildShader(const hecl::HMDLMeta& meta, const MaterialSet::Material& ma
|
|||
reflectionType = hecl::Backend::ReflectionType::Simple;
|
||||
else
|
||||
reflectionType = hecl::Backend::ReflectionType::None;
|
||||
hecl::Runtime::ShaderTag tag(mat.heclIr,
|
||||
hecl::Backend::ShaderTag tag(mat.heclIr,
|
||||
meta.colorCount, meta.uvCount, meta.weightCount,
|
||||
meta.weightCount * 4, boo::Primitive(meta.topology),
|
||||
reflectionType, true, true, true);
|
||||
return CModelShaders::g_ModelShaders->buildExtendedShader
|
||||
(tag, mat.heclIr, "CMDL", *CGraphics::g_BooFactory);
|
||||
return CModelShaders::BuildExtendedShader(tag, mat.heclIr);
|
||||
}
|
||||
|
||||
void SShader::BuildShaders(const hecl::HMDLMeta& meta,
|
||||
std::unordered_map<int, std::shared_ptr<hecl::Runtime::ShaderPipelines>>& shaders)
|
||||
std::unordered_map<int, CModelShaders::ShaderPipelines>& shaders)
|
||||
{
|
||||
shaders.reserve(m_matSet.materials.size());
|
||||
int idx = 0;
|
||||
|
@ -1294,7 +1276,6 @@ CModel::CModel(std::unique_ptr<u8[]>&& in, u32 /* dataLen */, IObjectStore* stor
|
|||
if (m_hmdlMeta.vertCount)
|
||||
m_staticVbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, vboData,
|
||||
m_hmdlMeta.vertStride, m_hmdlMeta.vertCount);
|
||||
m_staticVtxFmt = hecl::Runtime::HMDLData::NewVertexFormat(ctx, m_hmdlMeta, m_staticVbo.get(), m_ibo.get());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -5,158 +5,12 @@
|
|||
#include "Audio/g721.h"
|
||||
#include "amuse/DSPCodec.hpp"
|
||||
#include "CDvdRequest.hpp"
|
||||
#include "hecl/Pipeline.hpp"
|
||||
#include <turbojpeg.h>
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
static const char* VS_GLSL_YUV =
|
||||
"#version 330\n"
|
||||
BOO_GLSL_BINDING_HEAD
|
||||
"layout(location=0) in vec3 posIn;\n"
|
||||
"layout(location=1) in vec2 uvIn;\n"
|
||||
SPECTER_GLSL_VIEW_VERT_BLOCK
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" vec4 color;\n"
|
||||
" vec2 uv;\n"
|
||||
"};\n"
|
||||
"SBINDING(0) out VertToFrag vtf;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" vtf.uv = uvIn;\n"
|
||||
" vtf.color = mulColor;\n"
|
||||
" gl_Position = mv * vec4(posIn, 1.0);\n"
|
||||
" gl_Position = FLIPFROMGL(gl_Position);\n"
|
||||
"}\n";
|
||||
|
||||
static const char* FS_GLSL_YUV =
|
||||
"#version 330\n"
|
||||
BOO_GLSL_BINDING_HEAD
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" vec4 color;\n"
|
||||
" vec2 uv;\n"
|
||||
"};\n"
|
||||
"SBINDING(0) in VertToFrag vtf;\n"
|
||||
"TBINDING0 uniform sampler2D texY;\n"
|
||||
"TBINDING1 uniform sampler2D texU;\n"
|
||||
"TBINDING2 uniform sampler2D texV;\n"
|
||||
"layout(location=0) out vec4 colorOut;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" vec3 yuv;\n"
|
||||
" yuv.r = texture(texY, vtf.uv).r;\n"
|
||||
" yuv.g = texture(texU, vtf.uv).r;\n"
|
||||
" yuv.b = texture(texV, vtf.uv).r;\n"
|
||||
" yuv.r = 1.1643*(yuv.r-0.0625);\n"
|
||||
" yuv.g = yuv.g-0.5;\n"
|
||||
" yuv.b = yuv.b-0.5;\n"
|
||||
" colorOut = vec4(yuv.r+1.5958*yuv.b,\n"
|
||||
" yuv.r-0.39173*yuv.g-0.81290*yuv.b,\n"
|
||||
" yuv.r+2.017*yuv.g, 1.0) * vtf.color;\n"
|
||||
"}\n";
|
||||
|
||||
#if _WIN32
|
||||
static const char* VS_HLSL_YUV =
|
||||
"struct VertData\n"
|
||||
"{\n"
|
||||
" float3 posIn : POSITION;\n"
|
||||
" float2 uvIn : UV;\n"
|
||||
"};\n"
|
||||
SPECTER_HLSL_VIEW_VERT_BLOCK
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 position : SV_Position;\n"
|
||||
" float4 color : COLOR;\n"
|
||||
" float2 uv : UV;\n"
|
||||
"};\n"
|
||||
"VertToFrag main(in VertData v)\n"
|
||||
"{\n"
|
||||
" VertToFrag vtf;\n"
|
||||
" vtf.uv = v.uvIn;\n"
|
||||
" vtf.color = mulColor;\n"
|
||||
" vtf.position = mul(mv, float4(v.posIn, 1.0));\n"
|
||||
" return vtf;\n"
|
||||
"}\n";
|
||||
|
||||