2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-09 21:47:59 +00:00

boo lambda-API refactor

This commit is contained in:
Jack Andersen
2016-03-30 09:16:01 -10:00
parent 6b1c435d0c
commit 77a8ce5f17
21 changed files with 517 additions and 395 deletions

View File

@@ -222,13 +222,9 @@ public:
g_SpareTexture = spareTex;
}
static boo::IGraphicsBufferD* NewDynamicGPUBuffer(boo::BufferUse use, size_t stride, size_t count)
static boo::GraphicsDataToken CommitResources(const boo::FactoryCommitFunc& commitFunc)
{
return g_BooFactory->newDynamicBuffer(use, stride, count);
}
static boo::GraphicsDataToken CommitResources()
{
return g_BooFactory->commit();
return g_BooFactory->commitTransaction(commitFunc);
}
static void SetShaderDataBinding(boo::IShaderDataBinding* binding)
{

View File

@@ -22,31 +22,34 @@ void CLineRendererShaders::Initialize()
if (!CGraphics::g_BooFactory)
return;
switch (CGraphics::g_BooFactory->platform())
m_gfxToken = CGraphics::CommitResources(
[&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{
case boo::IGraphicsDataFactory::Platform::OGL:
m_bindFactory.reset(Initialize(*static_cast<boo::GLDataFactory*>(CGraphics::g_BooFactory)));
break;
switch (ctx.platform())
{
case boo::IGraphicsDataFactory::Platform::OGL:
m_bindFactory.reset(Initialize(static_cast<boo::GLDataFactory::Context&>(ctx)));
break;
#if _WIN32
case boo::IGraphicsDataFactory::Platform::D3D11:
case boo::IGraphicsDataFactory::Platform::D3D12:
m_bindFactory.reset(Initialize(*static_cast<boo::ID3DDataFactory*>(CGraphics::g_BooFactory)));
break;
case boo::IGraphicsDataFactory::Platform::D3D11:
case boo::IGraphicsDataFactory::Platform::D3D12:
m_bindFactory.reset(Initialize(static_cast<boo::ID3DDataFactory::Context&>(ctx)));
break;
#endif
#if BOO_HAS_METAL
case boo::IGraphicsDataFactory::Platform::Metal:
m_bindFactory.reset(Initialize(*static_cast<boo::MetalDataFactory*>(CGraphics::g_BooFactory)));
break;
case boo::IGraphicsDataFactory::Platform::Metal:
m_bindFactory.reset(Initialize(static_cast<boo::MetalDataFactory::Context&>(ctx)));
break;
#endif
#if BOO_HAS_VULKAN
case boo::IGraphicsDataFactory::Platform::Vulkan:
m_bindFactory.reset(Initialize(*static_cast<boo::VulkanDataFactory*>(CGraphics::g_BooFactory)));
break;
case boo::IGraphicsDataFactory::Platform::Vulkan:
m_bindFactory.reset(Initialize(static_cast<boo::VulkanDataFactory::Context&>(ctx)));
break;
#endif
default: break;
}
m_gfxToken = CGraphics::CommitResources();
default: break;
}
return true;
});
}
void CLineRenderer::Initialize()
@@ -82,8 +85,10 @@ struct SDrawUniform
zeus::CColor moduColor;
};
void CLineRendererShaders::BuildShaderDataBinding(CLineRenderer& renderer,
boo::ITexture* texture, bool additive)
void CLineRendererShaders::BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
CLineRenderer& renderer,
boo::ITexture* texture,
bool additive)
{
boo::IShaderPipeline* pipeline = nullptr;
if (texture)
@@ -101,7 +106,7 @@ void CLineRendererShaders::BuildShaderDataBinding(CLineRenderer& renderer,
pipeline = m_noTexAlpha;
}
m_bindFactory->BuildShaderDataBinding(renderer, pipeline, texture);
m_bindFactory->BuildShaderDataBinding(ctx, renderer, pipeline, texture);
}
CLineRenderer::CLineRenderer(EPrimitiveMode mode, u32 maxVerts, boo::ITexture* texture, bool additive)
@@ -128,12 +133,15 @@ CLineRenderer::CLineRenderer(EPrimitiveMode mode, u32 maxVerts, boo::ITexture* t
break;
}
m_vertBuf = CGraphics::NewDynamicGPUBuffer(boo::BufferUse::Vertex,
texture ? sizeof(SDrawVertTex) : sizeof(SDrawVertNoTex),
maxTriVerts);
m_uniformBuf = CGraphics::NewDynamicGPUBuffer(boo::BufferUse::Uniform, sizeof(SDrawUniform), 1);
CLineRendererShaders::BuildShaderDataBinding(*this, texture, additive);
m_gfxToken = CGraphics::CommitResources();
m_gfxToken = CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{
m_vertBuf = ctx.newDynamicBuffer(boo::BufferUse::Vertex,
texture ? sizeof(SDrawVertTex) : sizeof(SDrawVertNoTex),
maxTriVerts);
m_uniformBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(SDrawUniform), 1);
CLineRendererShaders::BuildShaderDataBinding(ctx, *this, texture, additive);
return true;
});
}
static rstl::reserved_vector<SDrawVertTex, 256> g_StaticLineVertsTex;

View File

@@ -16,7 +16,9 @@ class CLineRendererShaders
public:
struct IDataBindingFactory
{
virtual void BuildShaderDataBinding(CLineRenderer& renderer, boo::IShaderPipeline* pipeline,
virtual void BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
CLineRenderer& renderer,
boo::IShaderPipeline* pipeline,
boo::ITexture* texture)=0;
};
@@ -34,20 +36,21 @@ private:
static boo::GraphicsDataToken m_gfxToken;
public:
static IDataBindingFactory* Initialize(boo::GLDataFactory& factory);
static IDataBindingFactory* Initialize(boo::GLDataFactory::Context& ctx);
#if _WIN32
static IDataBindingFactory* Initialize(boo::ID3DDataFactory& factory);
static IDataBindingFactory* Initialize(boo::ID3DDataFactory::Context& ctx);
#endif
#if BOO_HAS_METAL
static IDataBindingFactory* Initialize(boo::MetalDataFactory& factory);
static IDataBindingFactory* Initialize(boo::MetalDataFactory::Context& ctx);
#endif
#if BOO_HAS_VULKAN
static IDataBindingFactory* Initialize(boo::VulkanDataFactory& factory);
static IDataBindingFactory* Initialize(boo::VulkanDataFactory::Context& ctx);
#endif
static void Initialize();
static void Shutdown();
static void BuildShaderDataBinding(CLineRenderer& renderer, boo::ITexture* texture, bool additive);
static void BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, CLineRenderer& renderer,
boo::ITexture* texture, bool additive);
};
}

View File

@@ -86,7 +86,8 @@ static const char* FS_GLSL_NOTEX =
struct OGLLineDataBindingFactory : CLineRendererShaders::IDataBindingFactory
{
void BuildShaderDataBinding(CLineRenderer& renderer, boo::IShaderPipeline* pipeline, boo::ITexture* texture)
void BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, CLineRenderer& renderer,
boo::IShaderPipeline* pipeline, boo::ITexture* texture)
{
boo::IVertexFormat* vtxFmt = nullptr;
int texCount = 0;
@@ -102,7 +103,7 @@ struct OGLLineDataBindingFactory : CLineRendererShaders::IDataBindingFactory
{renderer.m_vertBuf, nullptr, boo::VertexSemantic::Color},
{renderer.m_vertBuf, nullptr, boo::VertexSemantic::UV4}
};
vtxFmt = CGraphics::g_BooFactory->newVertexFormat(3, TexFmtTex);
vtxFmt = ctx.newVertexFormat(3, TexFmtTex);
}
else
{
@@ -111,31 +112,31 @@ struct OGLLineDataBindingFactory : CLineRendererShaders::IDataBindingFactory
{renderer.m_vertBuf, nullptr, boo::VertexSemantic::Position4},
{renderer.m_vertBuf, nullptr, boo::VertexSemantic::Color}
};
vtxFmt = CGraphics::g_BooFactory->newVertexFormat(2, TexFmtNoTex);
vtxFmt = ctx.newVertexFormat(2, TexFmtNoTex);
}
boo::IGraphicsBuffer* uniforms[] = {renderer.m_uniformBuf};
renderer.m_shaderBind = CGraphics::g_BooFactory->newShaderDataBinding(pipeline, vtxFmt, renderer.m_vertBuf,
nullptr, nullptr, 1, uniforms,
texCount, textures);
renderer.m_shaderBind = ctx.newShaderDataBinding(pipeline, vtxFmt, renderer.m_vertBuf,
nullptr, nullptr, 1, uniforms,
texCount, textures);
}
};
CLineRendererShaders::IDataBindingFactory* CLineRendererShaders::Initialize(boo::GLDataFactory& factory)
CLineRendererShaders::IDataBindingFactory* CLineRendererShaders::Initialize(boo::GLDataFactory::Context& ctx)
{
static const char* UniNames[] = {"LineUniform"};
m_texAlpha = factory.newShaderPipeline(VS_GLSL_TEX, FS_GLSL_TEX, 1, "texs", 1, UniNames,
m_texAlpha = ctx.newShaderPipeline(VS_GLSL_TEX, FS_GLSL_TEX, 1, "texs", 1, UniNames,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, false, true, false);
m_texAdditive = factory.newShaderPipeline(VS_GLSL_TEX, FS_GLSL_TEX, 1, "texs", 1, UniNames,
m_texAdditive = ctx.newShaderPipeline(VS_GLSL_TEX, FS_GLSL_TEX, 1, "texs", 1, UniNames,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
boo::Primitive::TriStrips, false, false, false);
m_noTexAlpha = factory.newShaderPipeline(VS_GLSL_NOTEX, FS_GLSL_NOTEX, 1, nullptr, 1, UniNames,
m_noTexAlpha = ctx.newShaderPipeline(VS_GLSL_NOTEX, FS_GLSL_NOTEX, 1, nullptr, 1, UniNames,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, false, true, false);
m_noTexAdditive = factory.newShaderPipeline(VS_GLSL_NOTEX, FS_GLSL_NOTEX, 1, nullptr, 1, UniNames,
m_noTexAdditive = ctx.newShaderPipeline(VS_GLSL_NOTEX, FS_GLSL_NOTEX, 1, nullptr, 1, UniNames,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
boo::Primitive::TriStrips, false, false, false);
@@ -145,7 +146,8 @@ CLineRendererShaders::IDataBindingFactory* CLineRendererShaders::Initialize(boo:
#if BOO_HAS_VULKAN
struct VulkanLineDataBindingFactory : CLineRendererShaders::IDataBindingFactory
{
void BuildShaderDataBinding(CLineRenderer& renderer, boo::IShaderPipeline* pipeline, boo::ITexture* texture)
void BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, CLineRenderer& renderer,
boo::IShaderPipeline* pipeline, boo::ITexture* texture)
{
int texCount = 0;
boo::ITexture* textures[1];
@@ -158,13 +160,13 @@ struct VulkanLineDataBindingFactory : CLineRendererShaders::IDataBindingFactory
boo::IGraphicsBuffer* uniforms[] = {renderer.m_uniformBuf};
renderer.m_shaderBind = CGraphics::g_BooFactory->newShaderDataBinding(pipeline, nullptr, renderer.m_vertBuf,
nullptr, nullptr, 1, uniforms,
texCount, textures);
renderer.m_shaderBind = ctx.newShaderDataBinding(pipeline, nullptr, renderer.m_vertBuf,
nullptr, nullptr, 1, uniforms,
texCount, textures);
}
};
CLineRendererShaders::IDataBindingFactory* CLineRendererShaders::Initialize(boo::VulkanDataFactory& factory)
CLineRendererShaders::IDataBindingFactory* CLineRendererShaders::Initialize(boo::VulkanDataFactory::Context& ctx)
{
static const boo::VertexElementDescriptor VtxFmtTex[] =
{
@@ -172,25 +174,25 @@ CLineRendererShaders::IDataBindingFactory* CLineRendererShaders::Initialize(boo:
{nullptr, nullptr, boo::VertexSemantic::Color},
{nullptr, nullptr, boo::VertexSemantic::UV4}
};
m_texVtxFmt = factory.newVertexFormat(3, VtxFmtTex);
m_texVtxFmt = ctx.newVertexFormat(3, VtxFmtTex);
static const boo::VertexElementDescriptor VtxFmtNoTex[] =
{
{nullptr, nullptr, boo::VertexSemantic::Position4},
{nullptr, nullptr, boo::VertexSemantic::Color}
};
m_noTexVtxFmt = factory.newVertexFormat(2, VtxFmtNoTex);
m_noTexVtxFmt = ctx.newVertexFormat(2, VtxFmtNoTex);
m_texAlpha = factory.newShaderPipeline(VS_GLSL_TEX, FS_GLSL_TEX, m_texVtxFmt,
m_texAlpha = ctx.newShaderPipeline(VS_GLSL_TEX, FS_GLSL_TEX, m_texVtxFmt,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, false, true, false);
m_texAdditive = factory.newShaderPipeline(VS_GLSL_TEX, FS_GLSL_TEX, m_texVtxFmt,
m_texAdditive = ctx.newShaderPipeline(VS_GLSL_TEX, FS_GLSL_TEX, m_texVtxFmt,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
boo::Primitive::TriStrips, false, false, false);
m_noTexAlpha = factory.newShaderPipeline(VS_GLSL_NOTEX, FS_GLSL_NOTEX, m_noTexVtxFmt,
m_noTexAlpha = ctx.newShaderPipeline(VS_GLSL_NOTEX, FS_GLSL_NOTEX, m_noTexVtxFmt,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, false, true, false);
m_noTexAdditive = factory.newShaderPipeline(VS_GLSL_NOTEX, FS_GLSL_NOTEX, m_noTexVtxFmt,
m_noTexAdditive = ctx.newShaderPipeline(VS_GLSL_NOTEX, FS_GLSL_NOTEX, m_noTexVtxFmt,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
boo::Primitive::TriStrips, false, false, false);

View File

@@ -7,6 +7,8 @@
#include "CToken.hpp"
#include "zeus/CAABox.hpp"
#include "boo/graphicsdev/IGraphicsDataFactory.hpp"
namespace urde
{
class IObjectStore;
@@ -25,37 +27,67 @@ struct CModelFlags
*/
};
class CBooSurface
{
};
class CBooModel
{
public:
struct CSurface
/* urde addition: doesn't require hacky stashing of
* pointers within loaded CMDL buffer */
struct CSurfaceView
{
const u8* m_data;
CBooModel* m_parent = nullptr;
CSurface* m_next = nullptr;
CSurfaceView* m_next = nullptr;
};
private:
std::vector<CSurface>* x0_surfaces;
std::vector<CSurfaceView>* x0_surfaces;
const u8* x4_matSet;
const void* x8_vbo;
const void* xc_ibo;
boo::IGraphicsBufferS* x8_vbo;
boo::IGraphicsBufferS* xc_ibo;
std::vector<TLockedToken<CTexture>>* x1c_textures;
zeus::CAABox x20_aabb;
CSurface* x38_firstUnsortedSurface = nullptr;
CSurface* x3c_firstSortedSurface = nullptr;
CSurfaceView* x38_firstUnsortedSurface = nullptr;
CSurfaceView* x3c_firstSortedSurface = nullptr;
bool x40_24_ : 1;
bool x40_25_ : 1;
u8 x41_shortNormals;
/* urde addition: boo! */
boo::GraphicsDataToken m_gfxToken;
boo::IGraphicsBufferD* m_uniformBuffer;
boo::IShaderDataBinding* m_shaderDataBinding;
void DrawAlphaSurfaces(const CModelFlags& flags) const;
void DrawNormalSurfaces(const CModelFlags& flags) const;
void DrawSurfaces(const CModelFlags& flags) const;
void DrawSurface(const CBooSurface& surf, const CModelFlags& flags) const;
public:
CBooModel(std::vector<CSurface>* surfaces, std::vector<TLockedToken<CTexture>>* textures,
const u8* matSet, const void* vbo, const void* ibo, const zeus::CAABox& aabb,
CBooModel(std::vector<CSurfaceView>* surfaces,
std::vector<TLockedToken<CTexture>>* textures,
const u8* matSet,
boo::IGraphicsBufferS* vbo, boo::IGraphicsBufferS* ibo,
const zeus::CAABox& aabb,
u8 shortNormals, bool unk);
static void MakeTexuresFromMats(const u8* dataIn,
std::vector<TLockedToken<CTexture>>& toksOut,
IObjectStore& store);
void TryLockTextures() const;
void UnlockTextures() const;
void DrawAlpha(const CModelFlags& flags) const;
void DrawNormal(const CModelFlags& flags) const;
void Draw(const CModelFlags& flags) const;
const u8* GetMaterialByIndex(int idx) const;
static bool g_DrawingOccluders;
static void SetDrawingOccluders(bool occ) {g_DrawingOccluders = occ;}
};
class CModel
@@ -69,11 +101,17 @@ public:
private:
std::unique_ptr<u8[]> x0_data;
u32 x4_dataLen;
std::vector<CBooModel::CSurface> x8_surfaces;
std::vector<CBooModel::CSurfaceView> x8_surfaces;
std::vector<SShader> x18_matSets;
std::unique_ptr<CBooModel> x28_modelInst;
CModel* x30_next = nullptr;
CModel* x34_prev = nullptr;
/* urde addition: boo! */
boo::GraphicsDataToken m_gfxToken;
boo::IGraphicsBufferS* m_vbo;
boo::IGraphicsBufferS* m_ibo;
public:
CModel(std::unique_ptr<u8[]>&& in, u32 dataLen, IObjectStore* store);
void Draw(const CModelFlags& flags) const;

View File

@@ -1,16 +1,19 @@
#include "Graphics/CModel.hpp"
#include "Graphics/CGraphics.hpp"
#include "hecl/HMDLMeta.hpp"
namespace urde
{
static logvisor::Module Log("urde::CModelBoo");
bool CBooModel::g_DrawingOccluders = false;
CBooModel::CBooModel(std::vector<CSurface>* surfaces, std::vector<TLockedToken<CTexture>>* textures,
const u8* matSet, const void* vbo, const void* ibo, const zeus::CAABox& aabb,
CBooModel::CBooModel(std::vector<CSurfaceView>* surfaces, std::vector<TLockedToken<CTexture>>* textures,
const u8* matSet, boo::IGraphicsBufferS* vbo, boo::IGraphicsBufferS* ibo, const zeus::CAABox& aabb,
u8 shortNormals, bool unk)
: x0_surfaces(surfaces), x4_matSet(matSet), x8_vbo(vbo), xc_ibo(ibo), x1c_textures(textures),
x20_aabb(aabb), x40_24_(unk), x40_25_(0), x41_shortNormals(shortNormals)
{
for (CSurface& surf : *x0_surfaces)
for (CSurfaceView& surf : *x0_surfaces)
surf.m_parent = this;
for (auto it=x0_surfaces->rbegin() ; it != x0_surfaces->rend() ; ++it)
@@ -46,6 +49,42 @@ void CBooModel::MakeTexuresFromMats(const u8* dataIn,
}
}
void CBooModel::TryLockTextures() const
{
}
void CBooModel::UnlockTextures() const
{
}
void CBooModel::DrawAlphaSurfaces(const CModelFlags& flags) const
{
}
void CBooModel::DrawNormalSurfaces(const CModelFlags& flags) const
{
}
void CBooModel::DrawSurfaces(const CModelFlags& flags) const
{
}
void CBooModel::DrawSurface(const CBooSurface& surf, const CModelFlags& flags) const
{
}
void CBooModel::DrawAlpha(const CModelFlags& flags) const
{
}
void CBooModel::DrawNormal(const CModelFlags& flags) const
{
}
void CBooModel::Draw(const CModelFlags& flags) const
{
}
const u8* CBooModel::GetMaterialByIndex(int idx) const
{
const u32* matOffs = reinterpret_cast<const u32*>(x4_matSet + (x1c_textures->size() + 1) * 4);
@@ -95,17 +134,31 @@ CModel::CModel(std::unique_ptr<u8[]>&& in, u32 dataLen, IObjectStore* store)
CBooModel::MakeTexuresFromMats(sec, shader.x0_textures, *store);
}
hecl::HMDLMeta hmdlMeta;
{
const u8* hmdlMetadata = MemoryFromPartData(dataCur, secSizeCur);
athena::io::MemoryReader r(hmdlMetadata, *secSizeCur);
hmdlMeta.read(r);
}
const u8* vboData = MemoryFromPartData(dataCur, secSizeCur);
const u8* iboData = MemoryFromPartData(dataCur, secSizeCur);
const u8* surfInfo = MemoryFromPartData(dataCur, secSizeCur);
m_gfxToken = CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{
m_vbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, vboData, hmdlMeta.vertStride, hmdlMeta.vertCount);
m_ibo = ctx.newStaticBuffer(boo::BufferUse::Index, iboData, 4, hmdlMeta.indexCount);
return true;
});
u32 surfCount = hecl::SBig(*reinterpret_cast<const u32*>(surfInfo));
x8_surfaces.reserve(surfCount);
for (u32 i=0 ; i<surfCount ; ++i)
{
const u8* sec = MemoryFromPartData(dataCur, secSizeCur);
x8_surfaces.emplace_back();
CBooModel::CSurface& surf = x8_surfaces.back();
CBooModel::CSurfaceView& surf = x8_surfaces.back();
surf.m_data = sec;
}
@@ -113,7 +166,7 @@ CModel::CModel(std::unique_ptr<u8[]>&& in, u32 dataLen, IObjectStore* store)
zeus::CAABox aabb(hecl::SBig(aabbPtr[0]), hecl::SBig(aabbPtr[1]), hecl::SBig(aabbPtr[2]),
hecl::SBig(aabbPtr[3]), hecl::SBig(aabbPtr[4]), hecl::SBig(aabbPtr[5]));
x28_modelInst = std::make_unique<CBooModel>(&x8_surfaces, &x18_matSets[0].x0_textures,
x18_matSets[0].x10_data, vboData, iboData,
x18_matSets[0].x10_data, m_vbo, m_ibo,
aabb, flags & 0x2, true);
}

View File

@@ -192,53 +192,56 @@ void CMoviePlayer::Initialize()
{
static const char* BlockNames[] = {"SpecterViewBlock"};
if (!CGraphics::g_BooFactory->bindingNeedsVertexFormat())
GraphicsData = CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{
boo::VertexElementDescriptor texvdescs[] =
if (!ctx.bindingNeedsVertexFormat())
{
{nullptr, nullptr, boo::VertexSemantic::Position4},
{nullptr, nullptr, boo::VertexSemantic::UV4}
};
YUVVTXFmt = CGraphics::g_BooFactory->newVertexFormat(2, texvdescs);
}
boo::VertexElementDescriptor texvdescs[] =
{
{nullptr, nullptr, boo::VertexSemantic::Position4},
{nullptr, nullptr, boo::VertexSemantic::UV4}
};
YUVVTXFmt = ctx.newVertexFormat(2, texvdescs);
}
switch (CGraphics::g_BooFactory->platform())
{
case boo::IGraphicsDataFactory::Platform::OGL:
YUVShaderPipeline = static_cast<boo::GLDataFactory*>(CGraphics::g_BooFactory)->newShaderPipeline
(VS_GLSL_YUV, FS_GLSL_YUV, 3, "texs", 1, BlockNames,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, false, false, false);
break;
switch (ctx.platform())
{
case boo::IGraphicsDataFactory::Platform::OGL:
YUVShaderPipeline = static_cast<boo::GLDataFactory::Context&>(ctx).newShaderPipeline
(VS_GLSL_YUV, FS_GLSL_YUV, 3, "texs", 1, BlockNames,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, false, false, false);
break;
#if _WIN32
case boo::IGraphicsDataFactory::Platform::D3D11:
case boo::IGraphicsDataFactory::Platform::D3D12:
YUVShaderPipeline = static_cast<boo::ID3DDataFactory*>(CGraphics::g_BooFactory)->newShaderPipeline
(VS_HLSL_YUV, FS_HLSL_YUV, ComPtr<ID3DBlob>(), ComPtr<ID3DBlob>(), ComPtr<ID3DBlob>(), YUVVTXFmt,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, false, false, false);
break;
case boo::IGraphicsDataFactory::Platform::D3D11:
case boo::IGraphicsDataFactory::Platform::D3D12:
YUVShaderPipeline = static_cast<boo::ID3DDataFactory::Context&>(ctx).newShaderPipeline
(VS_HLSL_YUV, FS_HLSL_YUV, ComPtr<ID3DBlob>(), ComPtr<ID3DBlob>(), ComPtr<ID3DBlob>(), YUVVTXFmt,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, false, false, false);
break;
#endif
#if BOO_HAS_METAL
case boo::IGraphicsDataFactory::Platform::Metal:
YUVShaderPipeline = static_cast<boo::MetalDataFactory*>(CGraphics::g_BooFactory)->newShaderPipeline
(VS_METAL_YUV, FS_METAL_YUV, YUVVTXFmt, 1,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, false, false, false);
break;
case boo::IGraphicsDataFactory::Platform::Metal:
YUVShaderPipeline = static_cast<boo::MetalDataFactory::Context&>(ctx).newShaderPipeline
(VS_METAL_YUV, FS_METAL_YUV, YUVVTXFmt, 1,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, false, false, false);
break;
#endif
#if BOO_HAS_VULKAN
case boo::IGraphicsDataFactory::Platform::Vulkan:
YUVShaderPipeline = static_cast<boo::VulkanDataFactory*>(CGraphics::g_BooFactory)->newShaderPipeline
(VS_GLSL_YUV, FS_GLSL_YUV, YUVVTXFmt,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, false, false, false);
break;
case boo::IGraphicsDataFactory::Platform::Vulkan:
YUVShaderPipeline = static_cast<boo::VulkanDataFactory::Context&>(ctx).newShaderPipeline
(VS_GLSL_YUV, FS_GLSL_YUV, YUVVTXFmt,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, false, false, false);
break;
#endif
default: break;
}
default: break;
}
return true;
});
GraphicsData = CGraphics::CommitResources();
TjHandle = tjInitDecompress();
}
@@ -410,81 +413,80 @@ CMoviePlayer::CMoviePlayer(const char* path, float preLoadSeconds, bool loop, bo
if (xf0_preLoadFrames > 0)
xa0_bufferQueue.reserve(xf0_preLoadFrames);
/* Establish GPU resources */
m_blockBuf = CGraphics::g_BooFactory->newDynamicBuffer(boo::BufferUse::Uniform,
sizeof(m_viewVertBlock), 1);
m_vertBuf = CGraphics::g_BooFactory->newDynamicBuffer(boo::BufferUse::Vertex,
sizeof(specter::View::TexShaderVert), 4);
boo::IVertexFormat* vtxFmt = YUVVTXFmt;
if (CGraphics::g_BooFactory->bindingNeedsVertexFormat())
/* All set for GPU resources */
m_token = CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{
boo::VertexElementDescriptor texvdescs[] =
{
{m_vertBuf, nullptr, boo::VertexSemantic::Position4},
{m_vertBuf, nullptr, boo::VertexSemantic::UV4}
};
vtxFmt = CGraphics::g_BooFactory->newVertexFormat(2, texvdescs);
}
m_blockBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(m_viewVertBlock), 1);
m_vertBuf = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(specter::View::TexShaderVert), 4);
/* Allocate textures here (rather than at decode time) */
x80_textures.reserve(3);
for (int i=0 ; i<3 ; ++i)
{
x80_textures.emplace_back();
CTHPTextureSet& set = x80_textures.back();
if (deinterlace)
boo::IVertexFormat* vtxFmt = YUVVTXFmt;
if (ctx.bindingNeedsVertexFormat())
{
/* urde addition: this way interlaced THPs don't look horrible */
set.Y[0] = CGraphics::g_BooFactory->newDynamicTexture(x6c_videoInfo.width,
x6c_videoInfo.height / 2,
boo::TextureFormat::I8);
set.Y[1] = CGraphics::g_BooFactory->newDynamicTexture(x6c_videoInfo.width,
x6c_videoInfo.height / 2,
boo::TextureFormat::I8);
set.U = CGraphics::g_BooFactory->newDynamicTexture(x6c_videoInfo.width / 2,
x6c_videoInfo.height / 2,
boo::TextureFormat::I8);
set.V = CGraphics::g_BooFactory->newDynamicTexture(x6c_videoInfo.width / 2,
x6c_videoInfo.height / 2,
boo::TextureFormat::I8);
boo::IGraphicsBuffer* bufs[] = {m_blockBuf};
for (int j=0 ; j<2 ; ++j)
boo::VertexElementDescriptor texvdescs[] =
{
boo::ITexture* texs[] = {set.Y[j], set.U, set.V};
set.binding[j] = CGraphics::g_BooFactory->newShaderDataBinding(YUVShaderPipeline, vtxFmt, m_vertBuf,
nullptr, nullptr, 1, bufs, 3, texs);
}
{m_vertBuf, nullptr, boo::VertexSemantic::Position4},
{m_vertBuf, nullptr, boo::VertexSemantic::UV4}
};
vtxFmt = ctx.newVertexFormat(2, texvdescs);
}
else
{
/* normal progressive presentation */
set.Y[0] = CGraphics::g_BooFactory->newDynamicTexture(x6c_videoInfo.width,
x6c_videoInfo.height,
boo::TextureFormat::I8);
set.U = CGraphics::g_BooFactory->newDynamicTexture(x6c_videoInfo.width / 2,
x6c_videoInfo.height / 2,
boo::TextureFormat::I8);
set.V = CGraphics::g_BooFactory->newDynamicTexture(x6c_videoInfo.width / 2,
x6c_videoInfo.height / 2,
boo::TextureFormat::I8);
boo::IGraphicsBuffer* bufs[] = {m_blockBuf};
boo::ITexture* texs[] = {set.Y[0], set.U, set.V};
set.binding[0] = CGraphics::g_BooFactory->newShaderDataBinding(YUVShaderPipeline, vtxFmt, m_vertBuf,
nullptr, nullptr, 1, bufs, 3, texs);
/* Allocate textures here (rather than at decode time) */
x80_textures.reserve(3);
for (int i=0 ; i<3 ; ++i)
{
x80_textures.emplace_back();
CTHPTextureSet& set = x80_textures.back();
if (deinterlace)
{
/* urde addition: this way interlaced THPs don't look horrible */
set.Y[0] = ctx.newDynamicTexture(x6c_videoInfo.width,
x6c_videoInfo.height / 2,
boo::TextureFormat::I8);
set.Y[1] = ctx.newDynamicTexture(x6c_videoInfo.width,
x6c_videoInfo.height / 2,
boo::TextureFormat::I8);
set.U = 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::IGraphicsBuffer* bufs[] = {m_blockBuf};
for (int j=0 ; j<2 ; ++j)
{
boo::ITexture* texs[] = {set.Y[j], set.U, set.V};
set.binding[j] = ctx.newShaderDataBinding(YUVShaderPipeline, vtxFmt, m_vertBuf,
nullptr, nullptr, 1, bufs, 3, texs);
}
}
else
{
/* normal progressive presentation */
set.Y[0] = ctx.newDynamicTexture(x6c_videoInfo.width,
x6c_videoInfo.height,
boo::TextureFormat::I8);
set.U = 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::IGraphicsBuffer* bufs[] = {m_blockBuf};
boo::ITexture* texs[] = {set.Y[0], set.U, set.V};
set.binding[0] = ctx.newShaderDataBinding(YUVShaderPipeline, vtxFmt, m_vertBuf,
nullptr, nullptr, 1, bufs, 3, texs);
}
if (xf4_25_hasAudio)
set.audioBuf.reset(new s16[x28_thpHead.maxAudioSamples * 2]);
}
if (xf4_25_hasAudio)
set.audioBuf.reset(new s16[x28_thpHead.maxAudioSamples * 2]);
}
return true;
});
/* 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)]);
/* All set for GPU resources */
m_token = CGraphics::CommitResources();
/* Schedule initial read */
PostDVDReadRequestIfNeeded();

View File

@@ -111,11 +111,12 @@ void CTexture::BuildI4FromGCN(CInputStream& in)
h /= 2;
}
boo::ITextureS* tmp;
m_booToken = CGraphics::g_BooFactory->newStaticTextureNoContext(x4_w, x6_h, x8_mips,
boo::TextureFormat::RGBA8,
buf.get(), texelCount * 4, tmp);
m_booTex = tmp;
m_booToken = CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{
m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::RGBA8,
buf.get(), texelCount * 4);
return true;
});
}
void CTexture::BuildI8FromGCN(CInputStream& in)
@@ -158,11 +159,12 @@ void CTexture::BuildI8FromGCN(CInputStream& in)
h /= 2;
}
boo::ITextureS* tmp;
m_booToken = CGraphics::g_BooFactory->newStaticTextureNoContext(x4_w, x6_h, x8_mips,
boo::TextureFormat::RGBA8,
buf.get(), texelCount * 4, tmp);
m_booTex = tmp;
m_booToken = CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{
m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::RGBA8,
buf.get(), texelCount * 4);
return true;
});
}
void CTexture::BuildIA4FromGCN(CInputStream& in)
@@ -206,11 +208,12 @@ void CTexture::BuildIA4FromGCN(CInputStream& in)
h /= 2;
}
boo::ITextureS* tmp;
m_booToken = CGraphics::g_BooFactory->newStaticTextureNoContext(x4_w, x6_h, x8_mips,
boo::TextureFormat::RGBA8,
buf.get(), texelCount * 4, tmp);
m_booTex = tmp;
m_booToken = CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{
m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::RGBA8,
buf.get(), texelCount * 4);
return true;
});
}
void CTexture::BuildIA8FromGCN(CInputStream& in)
@@ -254,11 +257,12 @@ void CTexture::BuildIA8FromGCN(CInputStream& in)
h /= 2;
}
boo::ITextureS* tmp;
m_booToken = CGraphics::g_BooFactory->newStaticTextureNoContext(x4_w, x6_h, x8_mips,
boo::TextureFormat::RGBA8,
buf.get(), texelCount * 4, tmp);
m_booTex = tmp;
m_booToken = CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{
m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::RGBA8,
buf.get(), texelCount * 4);
return true;
});
}
static std::vector<RGBA8> DecodePalette(int numEntries, CInputStream& in)
@@ -361,11 +365,12 @@ void CTexture::BuildC4FromGCN(CInputStream& in)
h /= 2;
}
boo::ITextureS* tmp;
m_booToken = CGraphics::g_BooFactory->newStaticTextureNoContext(x4_w, x6_h, x8_mips,
boo::TextureFormat::RGBA8,
buf.get(), texelCount * 4, tmp);
m_booTex = tmp;
m_booToken = CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{
m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::RGBA8,
buf.get(), texelCount * 4);
return true;
});
}
void CTexture::BuildC8FromGCN(CInputStream& in)
@@ -404,11 +409,12 @@ void CTexture::BuildC8FromGCN(CInputStream& in)
h /= 2;
}
boo::ITextureS* tmp;
m_booToken = CGraphics::g_BooFactory->newStaticTextureNoContext(x4_w, x6_h, x8_mips,
boo::TextureFormat::RGBA8,
buf.get(), texelCount * 4, tmp);
m_booTex = tmp;
m_booToken = CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{
m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::RGBA8,
buf.get(), texelCount * 4);
return true;
});
}
void CTexture::BuildC14X2FromGCN(CInputStream& in)
@@ -455,11 +461,12 @@ void CTexture::BuildRGB565FromGCN(CInputStream& in)
h /= 2;
}
boo::ITextureS* tmp;
m_booToken = CGraphics::g_BooFactory->newStaticTextureNoContext(x4_w, x6_h, x8_mips,
boo::TextureFormat::RGBA8,
buf.get(), texelCount * 4, tmp);
m_booTex = tmp;
m_booToken = CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{
m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::RGBA8,
buf.get(), texelCount * 4);
return true;
});
}
void CTexture::BuildRGB5A3FromGCN(CInputStream& in)
@@ -511,11 +518,12 @@ void CTexture::BuildRGB5A3FromGCN(CInputStream& in)
h /= 2;
}
boo::ITextureS* tmp;
m_booToken = CGraphics::g_BooFactory->newStaticTextureNoContext(x4_w, x6_h, x8_mips,
boo::TextureFormat::RGBA8,
buf.get(), texelCount * 4, tmp);
m_booTex = tmp;
m_booToken = CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{
m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::RGBA8,
buf.get(), texelCount * 4);
return true;
});
}
void CTexture::BuildRGBA8FromGCN(CInputStream& in)
@@ -567,11 +575,12 @@ void CTexture::BuildRGBA8FromGCN(CInputStream& in)
h /= 2;
}
boo::ITextureS* tmp;
m_booToken = CGraphics::g_BooFactory->newStaticTextureNoContext(x4_w, x6_h, x8_mips,
boo::TextureFormat::RGBA8,
buf.get(), texelCount * 4, tmp);
m_booTex = tmp;
m_booToken = CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{
m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::RGBA8,
buf.get(), texelCount * 4);
return true;
});
}
struct DXT1Block
@@ -630,11 +639,12 @@ void CTexture::BuildDXT1FromGCN(CInputStream& in)
h /= 2;
}
boo::ITextureS* tmp;
m_booToken = CGraphics::g_BooFactory->newStaticTextureNoContext(x4_w, x6_h, x8_mips,
boo::TextureFormat::DXT1,
buf.get(), blockCount * 8, tmp);
m_booTex = tmp;
m_booToken = CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{
m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::DXT1,
buf.get(), blockCount * 8);
return true;
});
}
CTexture::CTexture(CInputStream& in)