Tons of refactors and bug fixes

This commit is contained in:
Jack Andersen 2017-01-28 17:58:16 -10:00
parent d0d11eb700
commit d5c7efce58
78 changed files with 1276 additions and 618 deletions

View File

@ -368,7 +368,7 @@ bool FRME::Extract(const SpecBase &dataSpec,
for (const FRME::Widget& w : frme.widgets)
{
os << "binding = None\n"
"angle = Quaternion((0.0, 0.0, 0.0), 0)\n";
"angle = Quaternion((1.0, 0.0, 0.0), 0)\n";
if (w.type == SBIG('CAMR'))
{
using CAMRInfo = Widget::CAMRInfo;

View File

@ -93,15 +93,11 @@ static std::u16string::const_iterator CookTextureList(std::u16string& ret,
{
while (true)
{
auto end = str.find(u',', it - str.begin());
auto end = str.find_first_of(u",;", it - str.begin());
if (end == std::u16string::npos)
{
end = str.find(u';', it - str.begin());
if (end == std::u16string::npos)
Log.report(logvisor::Fatal,
"Missing comma/semicolon token while pasing font tag");
}
auto endIt = str.begin() + end + 1;
Log.report(logvisor::Fatal,
"Missing comma/semicolon token while pasing font tag");
auto endIt = str.begin() + end;
hecl::ProjectPath path =
UniqueIDBridge::MakePathFromString<UniqueID32>(
hecl::Char16ToUTF8(std::u16string(it, endIt)));

View File

@ -125,7 +125,7 @@ void CPersistentOptions::PutTo(CBitStreamWriter& w) const
for (const auto& world : memWorlds)
{
TLockedToken<CSaveWorld> saveWorld =
g_SimplePool->GetObj(SObjectTag{FOURCC('SAVW'), world.first});
g_SimplePool->GetObj(SObjectTag{FOURCC('SAVW'), world.second.GetSaveWorldAssetId()});
for (TEditorId cineId : saveWorld->GetCinematics())
w.WriteEncoded(GetCinematicState(world.first, cineId), 1);

View File

@ -152,7 +152,11 @@ CToken::CToken(const CToken& other)
: x0_objRef(other.x0_objRef)
{
if (x0_objRef)
{
++x0_objRef->x0_refCount;
if (other.x4_lockHeld)
Lock();
}
}
CToken::CToken(CToken&& other)
: x0_objRef(other.x0_objRef), x4_lockHeld(other.x4_lockHeld)

View File

@ -2,6 +2,7 @@
#include "Graphics/CLight.hpp"
#include "zeus/Math.hpp"
#include "CTimeProvider.hpp"
#include "Shaders/CTextSupportShader.hpp"
namespace urde
{
@ -114,6 +115,9 @@ void CGraphics::EndScene()
* so simulate field-flipping with XOR instead */
g_InterruptLastFrameUsedAbove ^= 1;
g_LastFrameUsedAbove = g_InterruptLastFrameUsedAbove;
/* Flush text instance buffers just before GPU command list submission */
CTextSupportShader::UpdateBuffers();
}
void CGraphics::SetAlphaCompare(ERglAlphaFunc comp0, u8 ref0, ERglAlphaOp op, ERglAlphaFunc comp1, u8 ref1)
@ -222,49 +226,99 @@ zeus::CMatrix4f CGraphics::CalculatePerspectiveMatrix(float fovy, float aspect,
zeus::CMatrix4f CGraphics::GetPerspectiveProjectionMatrix(bool forRenderer)
{
float rml = g_Proj.x8_right - g_Proj.x4_left;
float rpl = g_Proj.x8_right + g_Proj.x4_left;
float tmb = g_Proj.xc_top - g_Proj.x10_bottom;
float tpb = g_Proj.xc_top + g_Proj.x10_bottom;
float fpn = g_Proj.x18_far + g_Proj.x14_near;
float fmn = g_Proj.x18_far - g_Proj.x14_near;
if (g_Proj.x0_persp)
{
float rml = g_Proj.x8_right - g_Proj.x4_left;
float rpl = g_Proj.x8_right + g_Proj.x4_left;
float tmb = g_Proj.xc_top - g_Proj.x10_bottom;
float tpb = g_Proj.xc_top + g_Proj.x10_bottom;
float fpn = g_Proj.x18_far + g_Proj.x14_near;
float fmn = g_Proj.x18_far - g_Proj.x14_near;
if (!forRenderer)
{
return zeus::CMatrix4f(2.f * g_Proj.x14_near / rml, 0.f, rpl / rml, 0.f,
0.f, 2.f * g_Proj.x14_near / tmb, tpb / tmb, 0.f,
0.f, 0.f, -fpn / fmn, -2.f * g_Proj.x18_far * g_Proj.x14_near / fmn,
0.f, 0.f, -1.f, 0.f);
}
if (!forRenderer)
{
return zeus::CMatrix4f(2.f * g_Proj.x14_near / rml, 0.f, rpl / rml, 0.f,
0.f, 2.f * g_Proj.x14_near / tmb, tpb / tmb, 0.f,
0.f, 0.f, -fpn / fmn, -2.f * g_Proj.x18_far * g_Proj.x14_near / fmn,
0.f, 0.f, -1.f, 0.f);
}
switch (g_BooPlatform)
{
case boo::IGraphicsDataFactory::Platform::OpenGL:
default:
{
return zeus::CMatrix4f(2.f * g_Proj.x14_near / rml, 0.f, rpl / rml, 0.f,
0.f, 2.f * g_Proj.x14_near / tmb, tpb / tmb, 0.f,
0.f, 0.f, -fpn / fmn, -2.f * g_Proj.x18_far * g_Proj.x14_near / fmn,
0.f, 0.f, -1.f, 0.f);
switch (g_BooPlatform)
{
case boo::IGraphicsDataFactory::Platform::OpenGL:
default:
{
return zeus::CMatrix4f(2.f * g_Proj.x14_near / rml, 0.f, rpl / rml, 0.f,
0.f, 2.f * g_Proj.x14_near / tmb, tpb / tmb, 0.f,
0.f, 0.f, -fpn / fmn, -2.f * g_Proj.x18_far * g_Proj.x14_near / fmn,
0.f, 0.f, -1.f, 0.f);
}
case boo::IGraphicsDataFactory::Platform::D3D11:
case boo::IGraphicsDataFactory::Platform::D3D12:
case boo::IGraphicsDataFactory::Platform::Metal:
{
zeus::CMatrix4f mat2(2.f * g_Proj.x14_near / rml, 0.f, rpl / rml, 0.f,
0.f, 2.f * g_Proj.x14_near / tmb, tpb / tmb, 0.f,
0.f, 0.f, g_Proj.x18_far / fmn, g_Proj.x14_near * g_Proj.x18_far / fmn,
0.f, 0.f, -1.f, 0.f);
return PlusOneZ * mat2;
}
case boo::IGraphicsDataFactory::Platform::Vulkan:
{
zeus::CMatrix4f mat2(2.f * g_Proj.x14_near / rml, 0.f, rpl / rml, 0.f,
0.f, 2.f * g_Proj.x14_near / tmb, tpb / tmb, 0.f,
0.f, 0.f, -fpn / fmn, -2.f * g_Proj.x18_far * g_Proj.x14_near / fmn,
0.f, 0.f, -1.f, 0.f);
return PlusOneZFlip * mat2;
}
}
}
case boo::IGraphicsDataFactory::Platform::D3D11:
case boo::IGraphicsDataFactory::Platform::D3D12:
case boo::IGraphicsDataFactory::Platform::Metal:
else
{
zeus::CMatrix4f mat2(2.f * g_Proj.x14_near / rml, 0.f, rpl / rml, 0.f,
0.f, 2.f * g_Proj.x14_near / tmb, tpb / tmb, 0.f,
0.f, 0.f, g_Proj.x18_far / fmn, g_Proj.x14_near * g_Proj.x18_far / fmn,
0.f, 0.f, -1.f, 0.f);
return PlusOneZ * mat2;
}
case boo::IGraphicsDataFactory::Platform::Vulkan:
{
zeus::CMatrix4f mat2(2.f * g_Proj.x14_near / rml, 0.f, rpl / rml, 0.f,
0.f, 2.f * g_Proj.x14_near / tmb, tpb / tmb, 0.f,
0.f, 0.f, -fpn / fmn, -2.f * g_Proj.x18_far * g_Proj.x14_near / fmn,
0.f, 0.f, -1.f, 0.f);
return PlusOneZFlip * mat2;
}
float rml = g_Proj.x8_right - g_Proj.x4_left;
float rpl = g_Proj.x8_right + g_Proj.x4_left;
float tmb = g_Proj.xc_top - g_Proj.x10_bottom;
float tpb = g_Proj.xc_top + g_Proj.x10_bottom;
float fpn = g_Proj.x18_far + g_Proj.x14_near;
float fmn = g_Proj.x18_far - g_Proj.x14_near;
if (!forRenderer)
{
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);
}
switch (g_BooPlatform)
{
case boo::IGraphicsDataFactory::Platform::OpenGL:
default:
{
return zeus::CMatrix4f(2.f / rml, 0.f, 0.f, -rpl / rml,
0.f, 2.f / tmb, 0.f, -tpb / tmb,
0.f, 0.f, -2.f / fmn, -fpn / fmn,
0.f, 0.f, 0.f, 1.f);
}
case boo::IGraphicsDataFactory::Platform::D3D11:
case boo::IGraphicsDataFactory::Platform::D3D12:
case boo::IGraphicsDataFactory::Platform::Metal:
{
zeus::CMatrix4f mat2(2.f / rml, 0.f, 0.f, -rpl / rml,
0.f, 2.f / tmb, 0.f, -tpb / tmb,
0.f, 0.f, 1.f / fmn, -g_Proj.x14_near / fmn,
0.f, 0.f, 0.f, 1.f);
return PlusOneZ * mat2;
}
case boo::IGraphicsDataFactory::Platform::Vulkan:
{
zeus::CMatrix4f mat2(2.f / rml, 0.f, 0.f, -rpl / rml,
0.f, 2.f / tmb, 0.f, -tpb / tmb,
0.f, 0.f, 1.f / fmn, -g_Proj.x14_near / fmn,
0.f, 0.f, 0.f, 1.f);
return PlusOneZFlip * mat2;
}
}
}
}

View File

@ -8,7 +8,8 @@ if(WIN32)
Shaders/CThermalHotFilterHLSL.cpp
Shaders/CSpaceWarpFilterHLSL.cpp
Shaders/CCameraBlurFilterHLSL.cpp
Shaders/CXRayBlurFilterHLSL.cpp)
Shaders/CXRayBlurFilterHLSL.cpp
Shaders/CTextSupportShaderHLSL.cpp)
elseif(BOO_HAS_METAL)
set(PLAT_SRCS
Shaders/CLineRendererShadersMetal.cpp
@ -19,7 +20,8 @@ elseif(BOO_HAS_METAL)
Shaders/CThermalHotFilterMetal.cpp
Shaders/CSpaceWarpFilterMetal.cpp
Shaders/CCameraBlurFilterMetal.cpp
Shaders/CXRayBlurFilterMetal.cpp)
Shaders/CXRayBlurFilterMetal.cpp
Shaders/CTextSupportShaderMetal.cpp)
endif()
set(GRAPHICS_SOURCES
@ -48,12 +50,12 @@ set(GRAPHICS_SOURCES
Shaders/CTexturedQuadFilter.hpp Shaders/CTexturedQuadFilter.cpp Shaders/CTexturedQuadFilterGLSL.cpp
Shaders/CColoredQuadFilter.hpp Shaders/CColoredQuadFilter.cpp Shaders/CColoredQuadFilterGLSL.cpp
Shaders/CModelShaders.hpp Shaders/CModelShaders.cpp Shaders/CModelShadersGLSL.cpp
Shaders/CXrayOutlineFilter.hpp Shaders/CXrayOutlineFilter.cpp Shaders/CXrayOutlineFilterGLSL.cpp
Shaders/CThermalColdFilter.hpp Shaders/CThermalColdFilter.cpp Shaders/CThermalColdFilterGLSL.cpp
Shaders/CThermalHotFilter.hpp Shaders/CThermalHotFilter.cpp Shaders/CThermalHotFilterGLSL.cpp
Shaders/CSpaceWarpFilter.hpp Shaders/CSpaceWarpFilter.cpp Shaders/CSpaceWarpFilterGLSL.cpp
Shaders/CCameraBlurFilter.hpp Shaders/CCameraBlurFilter.cpp Shaders/CCameraBlurFilterGLSL.cpp
Shaders/CXRayBlurFilter.hpp Shaders/CXRayBlurFilter.cpp Shaders/CXRayBlurFilterGLSL.cpp
Shaders/CTextSupportShader.hpp Shaders/CTextSupportShader.cpp Shaders/CTextSupportShaderGLSL.cpp
${PLAT_SRCS})
runtime_add_list(Graphics GRAPHICS_SOURCES)

View File

@ -14,6 +14,19 @@ class CVParamTransfer;
class CTexture
{
public:
enum class EFontType
{
None = -1,
OneLayer = 0, /* Fill bit0 */
OneLayerOutline = 1, /* Fill bit0, Outline bit1 */
FourLayers = 2,
TwoLayersOutlines = 3, /* Fill bit0/2, Outline bit1/3 */
TwoLayers = 4, /* Fill bit0/1 and copied to bit2/3 */
TwoLayersOutlines2 = 8 /* Fill bit2/3, Outline bit0/1 */
};
private:
ETexelFormat x0_fmt;
u16 x4_w;
u16 x6_h;
@ -22,6 +35,7 @@ class CTexture
boo::ITexture* m_booTex;
boo::ITexture* m_paletteTex;
std::unique_ptr<u8[]> m_otex;
EFontType m_ftype = EFontType::None;
size_t ComputeMippedTexelCount();
size_t ComputeMippedBlockCountDXT1();
@ -38,6 +52,7 @@ class CTexture
void BuildDXT1FromGCN(CInputStream& in);
void BuildRGBA8(const void* data, size_t length);
void BuildC8(const void* data, size_t length);
void BuildC8Font(const void* data, EFontType ftype);
public:
CTexture(ETexelFormat, s16, s16, s32);
@ -57,6 +72,7 @@ public:
boo::ITexture* GetPaletteTexture() {return m_paletteTex;}
std::unique_ptr<u8[]> BuildMemoryCardTex(u32& sizeOut, ETexelFormat& fmtOut,
std::unique_ptr<u8[]>& paletteOut) const;
boo::ITexture* GetFontTexture(EFontType tp);
};
CFactoryFnReturn FTextureFactory(const urde::SObjectTag& tag,

View File

@ -684,6 +684,108 @@ void CTexture::BuildC8(const void* data, size_t length)
});
}
void CTexture::BuildC8Font(const void* data, EFontType ftype)
{
size_t texelCount = ComputeMippedTexelCount();
size_t layerCount;
switch (ftype)
{
case EFontType::OneLayer:
case EFontType::OneLayerOutline:
layerCount = 1;
break;
case EFontType::FourLayers:
layerCount = 4;
break;
case EFontType::TwoLayersOutlines:
case EFontType::TwoLayers:
case EFontType::TwoLayersOutlines2:
layerCount = 2;
break;
default: break;
}
uint32_t nentries = hecl::SBig(*reinterpret_cast<const uint32_t*>(data));
const u8* texels = reinterpret_cast<const u8*>(data) + 4 + nentries * 4;
std::unique_ptr<RGBA8[]> buf(new RGBA8[texelCount * layerCount]);
memset(buf.get(), 0, texelCount * layerCount * 4);
size_t w = x4_w;
size_t h = x6_h;
RGBA8* bufCur = buf.get();
for (size_t i=0 ; i<x8_mips ; ++i)
{
size_t tCount = w * h;
RGBA8* l0 = bufCur;
RGBA8* l1 = bufCur + tCount;
RGBA8* l2 = bufCur + tCount * 2;
RGBA8* l3 = bufCur + tCount * 3;
for (size_t j=0 ; j<tCount ; ++j)
{
u8 texel = texels[j];
switch (ftype)
{
case EFontType::OneLayer:
l0[j].r = (texel & 0x1) ? 0xff : 0;
l0[j].a = 0xff;
break;
case EFontType::OneLayerOutline:
l0[j].r = (texel & 0x1) ? 0xff : 0;
l0[j].g = (texel & 0x2) ? 0xff : 0;
l0[j].a = 0xff;
break;
case EFontType::FourLayers:
l0[j].r = (texel & 0x1) ? 0xff : 0;
l0[j].a = 0xff;
l1[j].r = (texel & 0x2) ? 0xff : 0;
l1[j].a = 0xff;
l2[j].r = (texel & 0x4) ? 0xff : 0;
l2[j].a = 0xff;
l3[j].r = (texel & 0x8) ? 0xff : 0;
l3[j].a = 0xff;
break;
case EFontType::TwoLayersOutlines:
l0[j].r = (texel & 0x1) ? 0xff : 0;
l0[j].g = (texel & 0x2) ? 0xff : 0;
l0[j].a = 0xff;
l1[j].r = (texel & 0x4) ? 0xff : 0;
l1[j].g = (texel & 0x8) ? 0xff : 0;
l1[j].a = 0xff;
break;
case EFontType::TwoLayers:
l0[j].r = (texel & 0x1) ? 0xff : 0;
l0[j].a = 0xff;
l1[j].r = (texel & 0x2) ? 0xff : 0;
l1[j].a = 0xff;
break;
case EFontType::TwoLayersOutlines2:
l0[j].r = (texel & 0x4) ? 0xff : 0;
l0[j].g = (texel & 0x1) ? 0xff : 0;
l0[j].a = 0xff;
l1[j].r = (texel & 0x8) ? 0xff : 0;
l1[j].g = (texel & 0x2) ? 0xff : 0;
l1[j].a = 0xff;
break;
default: break;
}
}
texels += tCount;
bufCur += tCount * layerCount;
if (w > 1)
w /= 2;
if (h > 1)
h /= 2;
}
m_booToken = CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{
m_booTex = ctx.newStaticArrayTexture(x4_w, x6_h, layerCount, x8_mips, boo::TextureFormat::RGBA8,
buf.get(), texelCount * layerCount * 4);
return true;
});
}
CTexture::CTexture(ETexelFormat fmt, s16 w, s16 h, s32 mips)
: x0_fmt(fmt)
, x4_w(w)
@ -746,6 +848,7 @@ CTexture::CTexture(std::unique_ptr<u8[]>&& in, u32 length, bool otex)
break;
case ETexelFormat::C8PC:
BuildC8(owned.get() + 12, length - 12);
otex = true;
break;
default:
Log.report(logvisor::Fatal, "invalid texture type %d for boo", int(x0_fmt));
@ -872,13 +975,24 @@ std::unique_ptr<u8[]> CTexture::BuildMemoryCardTex(u32& sizeOut, ETexelFormat& f
return ret;
}
boo::ITexture* CTexture::GetFontTexture(EFontType tp)
{
if (m_ftype != tp && x0_fmt == ETexelFormat::C8PC)
{
m_ftype = tp;
BuildC8Font(m_otex.get() + 12, m_ftype);
}
return m_booTex;
}
CFactoryFnReturn FTextureFactory(const urde::SObjectTag& tag,
std::unique_ptr<u8[]>&& in, u32 len,
const urde::CVParamTransfer& vparms,
CObjectReference* selfRef)
{
u32 u32Owned = vparms.GetOwnedObj<u32>();
return TToken<CTexture>::GetIObjObjectFor(std::make_unique<CTexture>(std::move(in), len,
vparms.GetOwnedObj<u32>() == SBIG('OTEX')));
u32Owned == SBIG('OTEX')));
}
}

View File

@ -62,6 +62,8 @@ void CCameraBlurFilter::draw(float amount)
CGraphics::g_BooMainCommandQueue->draw(0, 4);
}
void CCameraBlurFilter::Shutdown() {}
URDE_SPECIALIZE_SHADER(CCameraBlurFilter)
}

View File

@ -80,11 +80,11 @@ BOO_GLSL_BINDING_HEAD
URDE_DECL_SPECIALIZE_SHADER(CCameraBlurFilter)
static boo::IShaderPipeline* s_Pipeline = nullptr;
struct CCameraBlurFilterGLDataBindingFactory : TShader<CCameraBlurFilter>::IDataBindingFactory
{
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
boo::IShaderPipeline* pipeline,
boo::IVertexFormat*,
CCameraBlurFilter& filter)
{
boo::GLDataFactory::Context& cctx = static_cast<boo::GLDataFactory::Context&>(ctx);
@ -97,7 +97,7 @@ struct CCameraBlurFilterGLDataBindingFactory : TShader<CCameraBlurFilter>::IData
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf};
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
boo::ITexture* texs[] = {CGraphics::g_SpareTexture};
return cctx.newShaderDataBinding(pipeline,
return cctx.newShaderDataBinding(s_Pipeline,
ctx.newVertexFormat(2, VtxVmt), filter.m_vbo, nullptr, nullptr,
1, bufs, stages, nullptr, nullptr, 1, texs);
}
@ -107,35 +107,30 @@ struct CCameraBlurFilterGLDataBindingFactory : TShader<CCameraBlurFilter>::IData
struct CCameraBlurFilterVulkanDataBindingFactory : TShader<CCameraBlurFilter>::IDataBindingFactory
{
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
boo::IShaderPipeline* pipeline,
boo::IVertexFormat* vtxFmt,
CCameraBlurFilter& filter)
{
boo::VulkanDataFactory::Context& cctx = static_cast<boo::VulkanDataFactory::Context&>(ctx);
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf};
boo::ITexture* texs[] = {CGraphics::g_SpareTexture};
return cctx.newShaderDataBinding(pipeline, vtxFmt,
return cctx.newShaderDataBinding(s_Pipeline, vtxFmt,
filter.m_vbo, nullptr, nullptr, 1, bufs,
nullptr, nullptr, nullptr, 1, texs);
}
};
#endif
TShader<CCameraBlurFilter>::IDataBindingFactory* CCameraBlurFilter::Initialize(boo::GLDataFactory::Context& ctx,
boo::IShaderPipeline*& pipeOut)
TShader<CCameraBlurFilter>::IDataBindingFactory* CCameraBlurFilter::Initialize(boo::GLDataFactory::Context& ctx)
{
const char* texNames[] = {"sceneTex"};
const char* uniNames[] = {"CameraBlurUniform"};
pipeOut = ctx.newShaderPipeline(VS, FS, 1, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false);
s_Pipeline = ctx.newShaderPipeline(VS, FS, 1, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false);
return new CCameraBlurFilterGLDataBindingFactory;
}
#if BOO_HAS_VULKAN
TShader<CCameraBlurFilter>::IDataBindingFactory* CCameraBlurFilter::Initialize(boo::VulkanDataFactory::Context& ctx,
boo::IShaderPipeline*& pipeOut,
boo::IVertexFormat*& vtxFmtOut)
TShader<CCameraBlurFilter>::IDataBindingFactory* CCameraBlurFilter::Initialize(boo::VulkanDataFactory::Context& ctx)
{
const boo::VertexElementDescriptor VtxVmt[] =
{
@ -143,8 +138,8 @@ TShader<CCameraBlurFilter>::IDataBindingFactory* CCameraBlurFilter::Initialize(b
{nullptr, nullptr, boo::VertexSemantic::UV4}
};
vtxFmtOut = ctx.newVertexFormat(2, VtxVmt);
pipeOut = ctx.newShaderPipeline(VS, FS, vtxFmtOut, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false);
s_Pipeline = ctx.newShaderPipeline(VS, FS, vtxFmtOut, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false);
return new CCameraBlurFilterVulkanDataBindingFactory;
}
#endif

View File

@ -91,35 +91,34 @@ static const char* FS =
URDE_DECL_SPECIALIZE_SHADER(CCameraBlurFilter)
static boo::IVertexFormat* s_VtxFmt = nullptr;
static boo::IShaderPipeline* s_Pipeline = nullptr;
struct CCameraBlurFilterMetalDataBindingFactory : TShader<CCameraBlurFilter>::IDataBindingFactory
{
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
boo::IShaderPipeline* pipeline,
boo::IVertexFormat* vtxFmt,
CCameraBlurFilter& filter)
{
boo::MetalDataFactory::Context& cctx = static_cast<boo::MetalDataFactory::Context&>(ctx);
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf};
boo::ITexture* texs[] = {CGraphics::g_SpareTexture};
return cctx.newShaderDataBinding(pipeline, vtxFmt,
return cctx.newShaderDataBinding(s_Pipeline, s_VtxFmt,
filter.m_vbo, nullptr, nullptr, 1, bufs,
nullptr, nullptr, nullptr, 1, texs);
}
};
TShader<CCameraBlurFilter>::IDataBindingFactory* CCameraBlurFilter::Initialize(boo::MetalDataFactory::Context& ctx,
boo::IShaderPipeline*& pipeOut,
boo::IVertexFormat*& vtxFmtOut)
TShader<CCameraBlurFilter>::IDataBindingFactory* CCameraBlurFilter::Initialize(boo::MetalDataFactory::Context& ctx)
{
const boo::VertexElementDescriptor VtxVmt[] =
{
{nullptr, nullptr, boo::VertexSemantic::Position4},
{nullptr, nullptr, boo::VertexSemantic::UV4}
};
vtxFmtOut = ctx.newVertexFormat(2, VtxVmt);
pipeOut = ctx.newShaderPipeline(VS, FS, vtxFmtOut, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false);
s_VtxFmt = ctx.newVertexFormat(2, VtxVmt);
s_Pipeline = ctx.newShaderPipeline(VS, FS, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false);
return new CCameraBlurFilterMetalDataBindingFactory;
}

View File

@ -83,6 +83,8 @@ void CWideScreenFilter::SetViewportToFull()
CGraphics::g_BooMainCommandQueue->setViewport(rect);
}
void CColoredQuadFilter::Shutdown() {}
const zeus::CRectangle CColoredQuadFilter::DefaultRect = {0.f, 0.f, 1.f, 1.f};
URDE_SPECIALIZE_MULTI_BLEND_SHADER(CColoredQuadFilter)

View File

@ -45,11 +45,29 @@ BOO_GLSL_BINDING_HEAD
URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CColoredQuadFilter)
static boo::IShaderPipeline* s_AlphaPipeline = nullptr;
static boo::IShaderPipeline* s_AddPipeline = nullptr;
static boo::IShaderPipeline* s_MultPipeline = nullptr;
static boo::IShaderPipeline* SelectPipeline(CCameraFilterPass::EFilterType type)
{
switch (type)
{
case CCameraFilterPass::EFilterType::Blend:
return s_AlphaPipeline;
case CCameraFilterPass::EFilterType::Add:
return s_AddPipeline;
case CCameraFilterPass::EFilterType::Multiply:
return s_MultPipeline;
default:
return nullptr;
}
}
struct CColoredQuadFilterGLDataBindingFactory : TMultiBlendShader<CColoredQuadFilter>::IDataBindingFactory
{
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
boo::IShaderPipeline* pipeline,
boo::IVertexFormat*,
CCameraFilterPass::EFilterType type,
CColoredQuadFilter& filter)
{
boo::GLDataFactory::Context& cctx = static_cast<boo::GLDataFactory::Context&>(ctx);
@ -60,7 +78,7 @@ struct CColoredQuadFilterGLDataBindingFactory : TMultiBlendShader<CColoredQuadFi
};
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf};
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
return cctx.newShaderDataBinding(pipeline,
return cctx.newShaderDataBinding(SelectPipeline(type),
ctx.newVertexFormat(1, VtxVmt), filter.m_vbo, nullptr, nullptr,
1, bufs, stages, nullptr, nullptr, 0, nullptr);
}
@ -70,14 +88,12 @@ struct CColoredQuadFilterGLDataBindingFactory : TMultiBlendShader<CColoredQuadFi
struct CColoredQuadFilterVulkanDataBindingFactory : TMultiBlendShader<CColoredQuadFilter>::IDataBindingFactory
{
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
boo::IShaderPipeline* pipeline,
boo::IVertexFormat* vtxFmt,
CColoredQuadFilter& filter)
{
boo::VulkanDataFactory::Context& cctx = static_cast<boo::VulkanDataFactory::Context&>(ctx);
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf};
return cctx.newShaderDataBinding(pipeline, vtxFmt,
return cctx.newShaderDataBinding(SelectPipeline(type), vtxFmt,
filter.m_vbo, nullptr, nullptr, 1, bufs,
nullptr, nullptr, nullptr, 0, nullptr);
}
@ -85,40 +101,33 @@ struct CColoredQuadFilterVulkanDataBindingFactory : TMultiBlendShader<CColoredQu
#endif
TMultiBlendShader<CColoredQuadFilter>::IDataBindingFactory*
CColoredQuadFilter::Initialize(boo::GLDataFactory::Context& ctx,
boo::IShaderPipeline*& alphaPipeOut,
boo::IShaderPipeline*& additivePipeOut,
boo::IShaderPipeline*& colorMultiplyPipeOut)
CColoredQuadFilter::Initialize(boo::GLDataFactory::Context& ctx)
{
const char* uniNames[] = {"ColoredQuadUniform"};
alphaPipeOut = ctx.newShaderPipeline(VS, FS, 0, nullptr, 1, uniNames, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false);
additivePipeOut = ctx.newShaderPipeline(VS, FS, 0, nullptr, 1, uniNames, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::One, boo::Primitive::TriStrips, false, false, false);
colorMultiplyPipeOut = ctx.newShaderPipeline(VS, FS, 0, nullptr, 1, uniNames, boo::BlendFactor::SrcColor,
boo::BlendFactor::DstColor, boo::Primitive::TriStrips, false, false, false);
s_AlphaPipeline = ctx.newShaderPipeline(VS, FS, 0, nullptr, 1, uniNames, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false);
s_AddPipeline = ctx.newShaderPipeline(VS, FS, 0, nullptr, 1, uniNames, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::One, boo::Primitive::TriStrips, false, false, false);
s_MultPipeline = ctx.newShaderPipeline(VS, FS, 0, nullptr, 1, uniNames, boo::BlendFactor::SrcColor,
boo::BlendFactor::DstColor, boo::Primitive::TriStrips, false, false, false);
return new CColoredQuadFilterGLDataBindingFactory;
}
#if BOO_HAS_VULKAN
TMultiBlendShader<CColoredQuadFilter>::IDataBindingFactory*
CColoredQuadFilter::Initialize(boo::VulkanDataFactory::Context& ctx,
boo::IShaderPipeline*& alphaPipeOut,
boo::IShaderPipeline*& additivePipeOut,
boo::IShaderPipeline*& colorMultiplyPipeOut,
boo::IVertexFormat*& vtxFmtOut)
CColoredQuadFilter::Initialize(boo::VulkanDataFactory::Context& ctx)
{
const boo::VertexElementDescriptor VtxVmt[] =
{
{nullptr, nullptr, boo::VertexSemantic::Position4}
};
vtxFmtOut = ctx.newVertexFormat(1, VtxVmt);
alphaPipeOut = ctx.newShaderPipeline(VS, FS, vtxFmtOut, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false);
additivePipeOut = ctx.newShaderPipeline(VS, FS, vtxFmtOut, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::One, boo::Primitive::TriStrips, false, false, false);
colorMultiplyPipeOut = ctx.newShaderPipeline(VS, FS, vtxFmtOut, boo::BlendFactor::SrcColor,
boo::BlendFactor::DstColor, boo::Primitive::TriStrips, false, false, false);
s_AlphaPipeline = ctx.newShaderPipeline(VS, FS, vtxFmtOut, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false);
s_AddPipeline = ctx.newShaderPipeline(VS, FS, vtxFmtOut, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::One, boo::Primitive::TriStrips, false, false, false);
s_MultPipeline = ctx.newShaderPipeline(VS, FS, vtxFmtOut, boo::BlendFactor::SrcColor,
boo::BlendFactor::DstColor, boo::Primitive::TriStrips, false, false, false);
return new CColoredQuadFilterVulkanDataBindingFactory;
}
#endif

View File

@ -49,40 +49,55 @@ static const char* FS =
URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CColoredQuadFilter)
static boo::IVertexFormat* s_VtxFmt = nullptr;
static boo::IShaderPipeline* s_AlphaPipeline = nullptr;
static boo::IShaderPipeline* s_AddPipeline = nullptr;
static boo::IShaderPipeline* s_MultPipeline = nullptr;
static boo::IShaderPipeline* SelectPipeline(CCameraFilterPass::EFilterType type)
{
switch (type)
{
case CCameraFilterPass::EFilterType::Blend:
return s_AlphaPipeline;
case CCameraFilterPass::EFilterType::Add:
return s_AddPipeline;
case CCameraFilterPass::EFilterType::Multiply:
return s_MultPipeline;
default:
return nullptr;
}
}
struct CColoredQuadFilterMetalDataBindingFactory : TMultiBlendShader<CColoredQuadFilter>::IDataBindingFactory
{
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
boo::IShaderPipeline* pipeline,
boo::IVertexFormat* vtxFmt,
CCameraFilterPass::EFilterType type,
CColoredQuadFilter& filter)
{
boo::MetalDataFactory::Context& cctx = static_cast<boo::MetalDataFactory::Context&>(ctx);
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf};
return cctx.newShaderDataBinding(pipeline, vtxFmt,
return cctx.newShaderDataBinding(SelectPipeline(type), s_VtxFmt,
filter.m_vbo, nullptr, nullptr, 1, bufs,
nullptr, nullptr, nullptr, 0, nullptr);
}
};
TMultiBlendShader<CColoredQuadFilter>::IDataBindingFactory*
CColoredQuadFilter::Initialize(boo::MetalDataFactory::Context& ctx,
boo::IShaderPipeline*& alphaPipeOut,
boo::IShaderPipeline*& additivePipeOut,
boo::IShaderPipeline*& colorMultiplyPipeOut,
boo::IVertexFormat*& vtxFmtOut)
CColoredQuadFilter::Initialize(boo::MetalDataFactory::Context& ctx)
{
const boo::VertexElementDescriptor VtxVmt[] =
{
{nullptr, nullptr, boo::VertexSemantic::Position4}
};
vtxFmtOut = ctx.newVertexFormat(1, VtxVmt);
alphaPipeOut = ctx.newShaderPipeline(VS, FS, vtxFmtOut, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false);
additivePipeOut = ctx.newShaderPipeline(VS, FS, vtxFmtOut, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::One, boo::Primitive::TriStrips, false, false, false);
colorMultiplyPipeOut = ctx.newShaderPipeline(VS, FS, vtxFmtOut, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcColor,
boo::BlendFactor::DstColor, boo::Primitive::TriStrips, false, false, false);
s_VtxFmt = ctx.newVertexFormat(1, VtxVmt);
s_AlphaPipeline = ctx.newShaderPipeline(VS, FS, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false);
s_AddPipeline = ctx.newShaderPipeline(VS, FS, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::One, boo::Primitive::TriStrips, false, false, false);
s_MultPipeline = ctx.newShaderPipeline(VS, FS, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcColor,
boo::BlendFactor::DstColor, boo::Primitive::TriStrips, false, false, false);
return new CColoredQuadFilterMetalDataBindingFactory;
}

View File

@ -152,6 +152,8 @@ void CSpaceWarpFilter::draw(const zeus::CVector3f& pt)
CGraphics::g_BooMainCommandQueue->draw(0, 4);
}
void CSpaceWarpFilter::Shutdown() {}
URDE_SPECIALIZE_SHADER(CSpaceWarpFilter)
}

View File

@ -53,11 +53,11 @@ BOO_GLSL_BINDING_HEAD
URDE_DECL_SPECIALIZE_SHADER(CSpaceWarpFilter)
static boo::IShaderPipeline* s_Pipeline = nullptr;
struct CSpaceWarpFilterGLDataBindingFactory : TShader<CSpaceWarpFilter>::IDataBindingFactory
{
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
boo::IShaderPipeline* pipeline,
boo::IVertexFormat*,
CSpaceWarpFilter& filter)
{
boo::GLDataFactory::Context& cctx = static_cast<boo::GLDataFactory::Context&>(ctx);
@ -70,7 +70,7 @@ struct CSpaceWarpFilterGLDataBindingFactory : TShader<CSpaceWarpFilter>::IDataBi
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf};
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
boo::ITexture* texs[] = {CGraphics::g_SpareTexture, filter.m_warpTex};
return cctx.newShaderDataBinding(pipeline,
return cctx.newShaderDataBinding(s_Pipeline,
ctx.newVertexFormat(2, VtxVmt), filter.m_vbo, nullptr, nullptr,
1, bufs, stages, nullptr, nullptr, 2, texs);
}
@ -80,8 +80,6 @@ struct CSpaceWarpFilterGLDataBindingFactory : TShader<CSpaceWarpFilter>::IDataBi
struct CSpaceWarpFilterVulkanDataBindingFactory : TShader<CSpaceWarpFilter>::IDataBindingFactory
{
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
boo::IShaderPipeline* pipeline,
boo::IVertexFormat* vtxFmt,
CSpaceWarpFilter& filter)
{
boo::VulkanDataFactory::Context& cctx = static_cast<boo::VulkanDataFactory::Context&>(ctx);
@ -95,20 +93,17 @@ struct CSpaceWarpFilterVulkanDataBindingFactory : TShader<CSpaceWarpFilter>::IDa
};
#endif
TShader<CSpaceWarpFilter>::IDataBindingFactory* CSpaceWarpFilter::Initialize(boo::GLDataFactory::Context& ctx,
boo::IShaderPipeline*& pipeOut)
TShader<CSpaceWarpFilter>::IDataBindingFactory* CSpaceWarpFilter::Initialize(boo::GLDataFactory::Context& ctx)
{
const char* texNames[] = {"sceneTex", "indTex"};
const char* uniNames[] = {"SpaceWarpUniform"};
pipeOut = ctx.newShaderPipeline(VS, FS, 2, texNames, 1, uniNames, boo::BlendFactor::One,
boo::BlendFactor::Zero, boo::Primitive::TriStrips, false, false, false);
s_Pipeline = ctx.newShaderPipeline(VS, FS, 2, texNames, 1, uniNames, boo::BlendFactor::One,
boo::BlendFactor::Zero, boo::Primitive::TriStrips, false, false, false);
return new CSpaceWarpFilterGLDataBindingFactory;
}
#if BOO_HAS_VULKAN
TShader<CSpaceWarpFilter>::IDataBindingFactory* CSpaceWarpFilter::Initialize(boo::VulkanDataFactory::Context& ctx,
boo::IShaderPipeline*& pipeOut,
boo::IVertexFormat*& vtxFmtOut)
TShader<CSpaceWarpFilter>::IDataBindingFactory* CSpaceWarpFilter::Initialize(boo::VulkanDataFactory::Context& ctx)
{
const boo::VertexElementDescriptor VtxVmt[] =
{
@ -116,8 +111,8 @@ TShader<CSpaceWarpFilter>::IDataBindingFactory* CSpaceWarpFilter::Initialize(boo
{nullptr, nullptr, boo::VertexSemantic::UV4}
};
vtxFmtOut = ctx.newVertexFormat(2, VtxVmt);
pipeOut = ctx.newShaderPipeline(VS, FS, vtxFmtOut, boo::BlendFactor::One,
boo::BlendFactor::Zero, boo::Primitive::TriStrips, false, false, false);
s_Pipeline = ctx.newShaderPipeline(VS, FS, vtxFmtOut, boo::BlendFactor::One,
boo::BlendFactor::Zero, boo::Primitive::TriStrips, false, false, false);
return new CSpaceWarpFilterVulkanDataBindingFactory;
}
#endif

View File

@ -57,35 +57,34 @@ static const char* FS =
URDE_DECL_SPECIALIZE_SHADER(CSpaceWarpFilter)
static boo::IVertexFormat* s_VtxFmt = nullptr;
static boo::IShaderPipeline* s_Pipeline = nullptr;
struct CSpaceWarpFilterMetalDataBindingFactory : TShader<CSpaceWarpFilter>::IDataBindingFactory
{
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
boo::IShaderPipeline* pipeline,
boo::IVertexFormat* vtxFmt,
CSpaceWarpFilter& filter)
{
boo::MetalDataFactory::Context& cctx = static_cast<boo::MetalDataFactory::Context&>(ctx);
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf};
boo::ITexture* texs[] = {CGraphics::g_SpareTexture, filter.m_warpTex};
return cctx.newShaderDataBinding(pipeline, vtxFmt,
return cctx.newShaderDataBinding(s_Pipeline, s_VtxFmt,
filter.m_vbo, nullptr, nullptr, 1, bufs,
nullptr, nullptr, nullptr, 2, texs);
}
};
TShader<CSpaceWarpFilter>::IDataBindingFactory* CSpaceWarpFilter::Initialize(boo::MetalDataFactory::Context& ctx,
boo::IShaderPipeline*& pipeOut,
boo::IVertexFormat*& vtxFmtOut)
TShader<CSpaceWarpFilter>::IDataBindingFactory* CSpaceWarpFilter::Initialize(boo::MetalDataFactory::Context& ctx)
{
const boo::VertexElementDescriptor VtxVmt[] =
{
{nullptr, nullptr, boo::VertexSemantic::Position4},
{nullptr, nullptr, boo::VertexSemantic::UV4}
};
vtxFmtOut = ctx.newVertexFormat(2, VtxVmt);
pipeOut = ctx.newShaderPipeline(VS, FS, vtxFmtOut, CGraphics::g_ViewportSamples, boo::BlendFactor::One,
boo::BlendFactor::Zero, boo::Primitive::TriStrips, false, false, false);
s_VtxFmt = ctx.newVertexFormat(2, VtxVmt);
s_Pipeline = ctx.newShaderPipeline(VS, FS, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::One,
boo::BlendFactor::Zero, boo::Primitive::TriStrips, false, false, false);
return new CSpaceWarpFilterMetalDataBindingFactory;
}

View File

@ -0,0 +1,62 @@
#include "CTextSupportShader.hpp"
#include "GuiSys/CRasterFont.hpp"
namespace urde
{
boo::IVertexFormat* CTextSupportShader::s_TextVtxFmt = nullptr;
boo::IShaderPipeline* CTextSupportShader::s_TextAlphaPipeline = nullptr;
boo::IShaderPipeline* CTextSupportShader::s_TextAddPipeline = nullptr;
boo::IVertexFormat* CTextSupportShader::s_ImageVtxFmt = nullptr;
boo::IShaderPipeline* CTextSupportShader::s_ImageAlphaPipeline = nullptr;
boo::IShaderPipeline* CTextSupportShader::s_ImageAddPipeline = nullptr;
hecl::VertexBufferPool<CTextSupportShader::CharacterInstance> CTextSupportShader::s_CharInsts;
hecl::VertexBufferPool<CTextSupportShader::ImageInstance> CTextSupportShader::s_ImgInsts;
hecl::UniformBufferPool<CTextSupportShader::Uniform> CTextSupportShader::s_Uniforms;
void CTextSupportShader::CharacterInstance::SetMetrics(const CGlyph& glyph,
const zeus::CVector2i& offset)
{
float layer = glyph.GetLayer();
m_pos[0].assign(offset.x, 0.f, offset.y);
m_uv[0].assign(glyph.GetStartU(), 1.f - glyph.GetStartV(), layer);
m_pos[1].assign(offset.x + glyph.GetCellWidth(), 0.f, offset.y);
m_uv[1].assign(glyph.GetEndU(), 1.f - glyph.GetStartV(), layer);
m_pos[2].assign(offset.x, 0.f, offset.y + glyph.GetCellHeight());
m_uv[2].assign(glyph.GetStartU(), 1.f - glyph.GetEndV(), layer);
m_pos[3].assign(offset.x + glyph.GetCellWidth(), 0.f, offset.y + glyph.GetCellHeight());
m_uv[3].assign(glyph.GetEndU(), 1.f - glyph.GetEndV(), layer);
}
void CTextSupportShader::ImageInstance::SetMetrics(const zeus::CVector2f& imgSize,
const zeus::CVector2i& offset)
{
m_pos[0].assign(offset.x, 0.f, offset.y);
m_uv[0].assign(0.f, 1.f);
m_pos[1].assign(offset.x + imgSize.x, 0.f, offset.y);
m_uv[1].assign(1.f, 1.f);
m_pos[2].assign(offset.x, 0.f, offset.y + imgSize.y);
m_uv[2].assign(0.f, 0.f);
m_pos[3].assign(offset.x + imgSize.x, 0.f, offset.y + imgSize.y);
m_uv[3].assign(1.f, 0.f);
}
void CTextSupportShader::Shutdown()
{
s_CharInsts.doDestroy();
s_ImgInsts.doDestroy();
s_Uniforms.doDestroy();
}
URDE_SPECIALIZE_MULTI_BLEND_SHADER(CTextSupportShader)
}

View File

@ -0,0 +1,103 @@
#ifndef __URDE_CTEXTSUPPORTSHADER_HPP__
#define __URDE_CTEXTSUPPORTSHADER_HPP__
#include "TMultiBlendShader.hpp"
#include "GuiSys/CGuiWidget.hpp"
#include "hecl/VertexBufferPool.hpp"
#include "hecl/UniformBufferPool.hpp"
namespace urde
{
class CGlyph;
class CTextRenderBuffer;
class CTextSupportShader
{
friend struct CTextSupportShaderGLDataBindingFactory;
friend struct CTextSupportShaderVulkanDataBindingFactory;
friend struct CTextSupportShaderMetalDataBindingFactory;
friend struct CTextSupportShaderD3DDataBindingFactory;
friend class CTextRenderBuffer;
static boo::IVertexFormat* s_TextVtxFmt;
static boo::IShaderPipeline* s_TextAlphaPipeline;
static boo::IShaderPipeline* s_TextAddPipeline;
static boo::IVertexFormat* s_ImageVtxFmt;
static boo::IShaderPipeline* s_ImageAlphaPipeline;
static boo::IShaderPipeline* s_ImageAddPipeline;
struct Uniform
{
zeus::CMatrix4f m_mvp;
zeus::CColor m_uniformColor;
};
struct CharacterInstance
{
zeus::CVector3f m_pos[4];
zeus::CVector3f m_uv[4];
zeus::CColor m_fontColor;
zeus::CColor m_outlineColor;
void SetMetrics(const CGlyph& glyph, const zeus::CVector2i& offset);
};
struct ImageInstance
{
zeus::CVector3f m_pos[4];
zeus::CVector2f m_uv[4];
zeus::CColor m_color;
void SetMetrics(const zeus::CVector2f& imgSize, const zeus::CVector2i& offset);
};
static hecl::VertexBufferPool<CharacterInstance> s_CharInsts;
static hecl::VertexBufferPool<ImageInstance> s_ImgInsts;
static hecl::UniformBufferPool<Uniform> s_Uniforms;
public:
using _CLS = CTextSupportShader;
#include "TMultiBlendShaderDecl.hpp"
static boo::IShaderPipeline* SelectTextPipeline(CGuiWidget::EGuiModelDrawFlags df)
{
switch (df)
{
case CGuiWidget::EGuiModelDrawFlags::Shadeless:
case CGuiWidget::EGuiModelDrawFlags::Opaque:
case CGuiWidget::EGuiModelDrawFlags::Alpha:
return s_TextAlphaPipeline;
case CGuiWidget::EGuiModelDrawFlags::Additive:
case CGuiWidget::EGuiModelDrawFlags::AlphaAdditiveOverdraw:
return s_TextAddPipeline;
default:
return nullptr;
}
}
static boo::IShaderPipeline* SelectImagePipeline(CGuiWidget::EGuiModelDrawFlags df)
{
switch (df)
{
case CGuiWidget::EGuiModelDrawFlags::Shadeless:
case CGuiWidget::EGuiModelDrawFlags::Opaque:
case CGuiWidget::EGuiModelDrawFlags::Alpha:
return s_ImageAlphaPipeline;
case CGuiWidget::EGuiModelDrawFlags::Additive:
case CGuiWidget::EGuiModelDrawFlags::AlphaAdditiveOverdraw:
return s_ImageAddPipeline;
default:
return nullptr;
}
}
static void UpdateBuffers()
{
s_CharInsts.updateBuffers();
s_ImgInsts.updateBuffers();
s_Uniforms.updateBuffers();
}
};
}
#endif // __URDE_CTEXTSUPPORTSHADER_HPP__

View File

@ -0,0 +1,169 @@
#include "CTextSupportShader.hpp"
#include "GuiSys/CTextRenderBuffer.hpp"
#include "TMultiBlendShader.hpp"
#include "Graphics/CTexture.hpp"
namespace urde
{
static const char* TextVS =
"#version 330\n"
BOO_GLSL_BINDING_HEAD
"layout(location=0) in vec4 posIn[4];\n"
"layout(location=4) in vec4 uvIn[4];\n"
"layout(location=8) in vec4 fontColorIn;\n"
"layout(location=9) in vec4 outlineColorIn;\n"
"\n"
"UBINDING0 uniform TextSupportUniform\n"
"{\n"
" mat4 mtx;\n"
" vec4 color;\n"
"};\n"
"\n"
"struct VertToFrag\n"
"{\n"
" vec4 fontColor;\n"
" vec4 outlineColor;\n"
" vec3 uv;\n"
"};\n"
"\n"
"SBINDING(0) out VertToFrag vtf;\n"
"void main()\n"
"{\n"
" vtf.fontColor = color * fontColorIn;\n"
" vtf.outlineColor = color * outlineColorIn;\n"
" vtf.uv = uvIn[gl_VertexID].xyz;\n"
" gl_Position = mtx * vec4(posIn[gl_VertexID].xyz, 1.0);\n"
" gl_Position = FLIPFROMGL(gl_Position);\n"
"}\n";
static const char* TextFS =
"#version 330\n"
BOO_GLSL_BINDING_HEAD
"struct VertToFrag\n"
"{\n"
" vec4 fontColor;\n"
" vec4 outlineColor;\n"
" vec3 uv;\n"
"};\n"
"\n"
"SBINDING(0) in VertToFrag vtf;\n"
"layout(location=0) out vec4 colorOut;\n"
"TBINDING0 uniform sampler2DArray tex;\n"
"void main()\n"
"{\n"
" vec4 texel = texture(tex, vtf.uv);\n"
" colorOut = vtf.fontColor * texel.r + vtf.outlineColor * texel.g;\n"
"}\n";
static const char* ImgVS =
"#version 330\n"
BOO_GLSL_BINDING_HEAD
"layout(location=0) in vec3 posIn[4];\n"
"layout(location=4) in vec2 uvIn[4];\n"
"layout(location=8) in vec4 colorIn;\n"
"\n"
"UBINDING0 uniform TextSupportUniform\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 * colorIn;\n"
" vtf.uv = uvIn[gl_VertexID];\n"
" gl_Position = mtx * vec4(posIn[gl_VertexID].xyz, 1.0);\n"
" gl_Position = FLIPFROMGL(gl_Position);\n"
"}\n";
static const char* ImgFS =
"#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"
" vec4 texel = texture(tex, vtf.uv);\n"
" colorOut = vtf.color * texel;\n"
"}\n";
TMultiBlendShader<CTextSupportShader>::IDataBindingFactory*
CTextSupportShader::Initialize(boo::GLDataFactory::Context& ctx)
{
const char* texNames[] = {"tex"};
const char* uniNames[] = {"TextSupportUniform"};
s_TextAlphaPipeline = ctx.newShaderPipeline(TextVS, TextFS, 1, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false);
s_TextAddPipeline = ctx.newShaderPipeline(TextVS, TextFS, 1, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::One, boo::Primitive::TriStrips, false, false, false);
s_ImageAlphaPipeline = ctx.newShaderPipeline(ImgVS, ImgFS, 1, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false);
s_ImageAddPipeline = ctx.newShaderPipeline(ImgVS, ImgFS, 1, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::One, boo::Primitive::TriStrips, false, false, false);
return nullptr;
}
#if BOO_HAS_VULKAN
TMultiBlendShader<CTextSupportShader>::IDataBindingFactory*
CTextSupportShader::Initialize(boo::VulkanDataFactory::Context& ctx)
{
boo::VertexElementDescriptor TextVtxVmt[] =
{
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 0},
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 1},
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 2},
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 3},
{nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 0},
{nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 1},
{nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 2},
{nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 3},
{nullptr, nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced, 0},
{nullptr, nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced, 1},
};
s_TextVtxFmt = ctx.newVertexFormat(10, TextVtxVmt);
s_TextAlphaPipeline = ctx.newShaderPipeline(TextVS, TextFS, s_TextVtxFmt, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false);
s_TextAddPipeline = ctx.newShaderPipeline(TextVS, TextFS, s_TextVtxFmt, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::One, boo::Primitive::TriStrips, false, false, false);
boo::VertexElementDescriptor ImageVtxVmt[] =
{
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 0},
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 1},
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 2},
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 3},
{nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 0},
{nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 1},
{nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 2},
{nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 3},
{nullptr, nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced, 0},
};
s_ImageVtxFmt = ctx.newVertexFormat(9, ImageVtxVmt);
s_ImageAlphaPipeline = ctx.newShaderPipeline(ImgVS, ImgFS, s_ImageVtxFmt, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false);
s_ImageAddPipeline = ctx.newShaderPipeline(ImgVS, ImgFS, s_ImageVtxFmt, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::One, boo::Primitive::TriStrips, false, false, false);
return nullptr;
}
#endif
}

View File

@ -0,0 +1,162 @@
#include "CTextSupportShader.hpp"
#include "GuiSys/CTextRenderBuffer.hpp"
#include "TMultiBlendShader.hpp"
#include "Graphics/CTexture.hpp"
namespace urde
{
static const char* TextVS =
"#include <metal_stdlib>\n"
"using namespace metal;\n"
"struct InstData\n"
"{\n"
" float4 posIn[4];\n"
" float4 uvIn[4];\n"
" float4 fontColorIn;\n"
" float4 outlineColorIn;\n"
"};\n"
"\n"
"struct TextSupportUniform\n"
"{\n"
" float4x4 mtx;\n"
" float4 color;\n"
"};\n"
"\n"
"struct VertToFrag\n"
"{\n"
" float4 pos [[ position ]];\n"
" float4 fontColor;\n"
" float4 outlineColor;\n"
" float3 uv;\n"
"};\n"
"\n"
"vertex VertToFrag vmain(constant InstData* instArr [[ buffer(1) ]],\n"
" uint vertId [[ vertex_id ]], uint instId [[ instance_id ]],\n"
" constant TextSupportUniform& uData [[ buffer(2) ]])\n"
"{\n"
" VertToFrag vtf;\n"
" constant InstData& inst = instArr[instId];\n"
" vtf.fontColor = uData.color * inst.fontColorIn;\n"
" vtf.outlineColor = uData.color * inst.outlineColorIn;\n"
" vtf.uv = inst.uvIn[vertId].xyz;\n"
" vtf.pos = uData.mtx * float4(inst.posIn[vertId].xyz, 1.0);\n"
" return vtf;\n"
"}\n";
static const char* TextFS =
"#include <metal_stdlib>\n"
"using namespace metal;\n"
"constexpr sampler samp(address::repeat);\n"
"struct VertToFrag\n"
"{\n"
" float4 pos [[ position ]];\n"
" float4 fontColor;\n"
" float4 outlineColor;\n"
" float3 uv;\n"
"};\n"
"\n"
"fragment float4 fmain(VertToFrag vtf [[ stage_in ]],\n"
" texture2d_array<float> tex [[ texture(0) ]])\n"
"{\n"
" float4 texel = tex.sample(samp, vtf.uv.xy, vtf.uv.z);\n"
" return vtf.fontColor * texel.r + vtf.outlineColor * texel.g;\n"
"}\n";
static const char* ImgVS =
"#include <metal_stdlib>\n"
"using namespace metal;\n"
"struct InstData\n"
"{\n"
" float4 posIn[4];\n"
" float4 uvIn[4];\n"
" float4 colorIn;\n"
"};\n"
"\n"
"struct TextSupportUniform\n"
"{\n"
" float4x4 mtx;\n"
" float4 color;\n"
"};\n"
"\n"
"struct VertToFrag\n"
"{\n"
" float4 pos [[ position ]];\n"
" float4 color;\n"
" float2 uv;\n"
"};\n"
"\n"
"vertex VertToFrag vmain(constant InstData* instArr [[ buffer(1) ]],\n"
" uint vertId [[ vertex_id ]], uint instId [[ instance_id ]],\n"
" constant TextSupportUniform& uData [[ buffer(2) ]])\n"
"{\n"
" VertToFrag vtf;\n"
" constant InstData& inst = instArr[instId];\n"
" vtf.color = uData.color * inst.colorIn;\n"
" vtf.uv = inst.uvIn[vertId].xy;\n"
" vtf.pos = uData.mtx * float4(inst.posIn[vertId].xyz, 1.0);\n"
" return vtf;\n"
"}\n";
static const char* ImgFS =
"#include <metal_stdlib>\n"
"using namespace metal;\n"
"constexpr sampler samp(address::repeat);\n"
"struct VertToFrag\n"
"{\n"
" float4 pos [[ position ]];\n"
" float4 color;\n"
" float2 uv;\n"
"};\n"
"\n"
"fragment float4 fmain(VertToFrag vtf [[ stage_in ]],\n"
" texture2d<float> tex [[ texture(0) ]])\n"
"{\n"
" float4 texel = tex.sample(samp, vtf.uv);\n"
" return vtf.color * texel;\n"
"}\n";
TMultiBlendShader<CTextSupportShader>::IDataBindingFactory*
CTextSupportShader::Initialize(boo::MetalDataFactory::Context& ctx)
{
boo::VertexElementDescriptor TextVtxVmt[] =
{
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 0},
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 1},
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 2},
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 3},
{nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 0},
{nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 1},
{nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 2},
{nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 3},
{nullptr, nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced, 0},
{nullptr, nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced, 1},
};
s_TextVtxFmt = ctx.newVertexFormat(10, TextVtxVmt);
s_TextAlphaPipeline = ctx.newShaderPipeline(TextVS, TextFS, s_TextVtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false);
s_TextAddPipeline = ctx.newShaderPipeline(TextVS, TextFS, s_TextVtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::One, boo::Primitive::TriStrips, false, false, false);
boo::VertexElementDescriptor ImageVtxVmt[] =
{
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 0},
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 1},
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 2},
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 3},
{nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 0},
{nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 1},
{nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 2},
{nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 3},
{nullptr, nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced, 0},
};
s_ImageVtxFmt = ctx.newVertexFormat(9, ImageVtxVmt);
s_ImageAlphaPipeline = ctx.newShaderPipeline(ImgVS, ImgFS, s_ImageVtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false);
s_ImageAddPipeline = ctx.newShaderPipeline(ImgVS, ImgFS, s_ImageVtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::One, boo::Primitive::TriStrips, false, false, false);
return nullptr;
}
}

View File

@ -77,6 +77,8 @@ void CTexturedQuadFilter::drawCropped(const zeus::CColor& color, float uvScale)
const zeus::CRectangle CTexturedQuadFilter::DefaultRect = {0.f, 0.f, 1.f, 1.f};
void CTexturedQuadFilter::Shutdown() {}
URDE_SPECIALIZE_MULTI_BLEND_SHADER(CTexturedQuadFilter)
CTexturedQuadFilterAlpha::CTexturedQuadFilterAlpha(CCameraFilterPass::EFilterType type, boo::ITexture* tex)
@ -98,6 +100,8 @@ CTexturedQuadFilterAlpha::CTexturedQuadFilterAlpha(CCameraFilterPass::EFilterTyp
m_tex = tex;
}
void CTexturedQuadFilterAlpha::Shutdown() {}
URDE_SPECIALIZE_MULTI_BLEND_SHADER(CTexturedQuadFilterAlpha)
}

View File

@ -97,11 +97,48 @@ BOO_GLSL_BINDING_HEAD
URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CTexturedQuadFilter)
static boo::IShaderPipeline* s_AlphaPipeline = nullptr;
static boo::IShaderPipeline* s_AddPipeline = nullptr;
static boo::IShaderPipeline* s_MultPipeline = nullptr;
static boo::IShaderPipeline* SelectPipeline(CCameraFilterPass::EFilterType type)
{
switch (type)
{
case CCameraFilterPass::EFilterType::Blend:
return s_AlphaPipeline;
case CCameraFilterPass::EFilterType::Add:
return s_AddPipeline;
case CCameraFilterPass::EFilterType::Multiply:
return s_MultPipeline;
default:
return nullptr;
}
}
static boo::IShaderPipeline* s_AAlphaPipeline = nullptr;
static boo::IShaderPipeline* s_AAddPipeline = nullptr;
static boo::IShaderPipeline* s_AMultPipeline = nullptr;
static boo::IShaderPipeline* SelectAlphaPipeline(CCameraFilterPass::EFilterType type)
{
switch (type)
{
case CCameraFilterPass::EFilterType::Blend:
return s_AAlphaPipeline;
case CCameraFilterPass::EFilterType::Add:
return s_AAddPipeline;
case CCameraFilterPass::EFilterType::Multiply:
return s_AMultPipeline;
default:
return nullptr;
}
}
struct CTexturedQuadFilterGLDataBindingFactory : TMultiBlendShader<CTexturedQuadFilter>::IDataBindingFactory
{
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
boo::IShaderPipeline* pipeline,
boo::IVertexFormat*,
CCameraFilterPass::EFilterType type,
CTexturedQuadFilter& filter)
{
boo::GLDataFactory::Context& cctx = static_cast<boo::GLDataFactory::Context&>(ctx);
@ -114,7 +151,7 @@ struct CTexturedQuadFilterGLDataBindingFactory : TMultiBlendShader<CTexturedQuad
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf};
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
boo::ITexture* texs[] = {filter.m_booTex};
return cctx.newShaderDataBinding(pipeline,
return cctx.newShaderDataBinding(SelectPipeline(type),
ctx.newVertexFormat(2, VtxVmt), filter.m_vbo, nullptr, nullptr,
1, bufs, stages, nullptr, nullptr, 1, texs);
}
@ -124,15 +161,14 @@ struct CTexturedQuadFilterGLDataBindingFactory : TMultiBlendShader<CTexturedQuad
struct CTexturedQuadFilterVulkanDataBindingFactory : TMultiBlendShader<CTexturedQuadFilter>::IDataBindingFactory
{
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
boo::IShaderPipeline* pipeline,
boo::IVertexFormat* vtxFmt,
CCameraFilterPass::EFilterType type,
CTexturedQuadFilter& filter)
{
boo::VulkanDataFactory::Context& cctx = static_cast<boo::VulkanDataFactory::Context&>(ctx);
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf};
boo::ITexture* texs[] = {filter.m_booTex};
return cctx.newShaderDataBinding(pipeline, vtxFmt,
return cctx.newShaderDataBinding(SelectPipeline(type), vtxFmt,
filter.m_vbo, nullptr, nullptr, 1, bufs,
nullptr, nullptr, nullptr, 1, texs);
}
@ -140,29 +176,22 @@ struct CTexturedQuadFilterVulkanDataBindingFactory : TMultiBlendShader<CTextured
#endif
TMultiBlendShader<CTexturedQuadFilter>::IDataBindingFactory*
CTexturedQuadFilter::Initialize(boo::GLDataFactory::Context& ctx,
boo::IShaderPipeline*& alphaPipeOut,
boo::IShaderPipeline*& additivePipeOut,
boo::IShaderPipeline*& colorMultiplyPipeOut)
CTexturedQuadFilter::Initialize(boo::GLDataFactory::Context& ctx)
{
const char* texNames[] = {"tex"};
const char* uniNames[] = {"TexuredQuadUniform"};
alphaPipeOut = ctx.newShaderPipeline(VSNoFlip, FS, 1, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false);
additivePipeOut = ctx.newShaderPipeline(VSNoFlip, FS, 1, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::One, boo::Primitive::TriStrips, false, false, false);
colorMultiplyPipeOut = ctx.newShaderPipeline(VSNoFlip, FS, 1, texNames, 1, uniNames, boo::BlendFactor::SrcColor,
boo::BlendFactor::DstColor, boo::Primitive::TriStrips, false, false, false);
s_AlphaPipeline = ctx.newShaderPipeline(VSNoFlip, FS, 1, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false);
s_AddPipeline = ctx.newShaderPipeline(VSNoFlip, FS, 1, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::One, boo::Primitive::TriStrips, false, false, false);
s_MultPipeline = ctx.newShaderPipeline(VSNoFlip, FS, 1, texNames, 1, uniNames, boo::BlendFactor::SrcColor,
boo::BlendFactor::DstColor, boo::Primitive::TriStrips, false, false, false);
return new CTexturedQuadFilterGLDataBindingFactory;
}
#if BOO_HAS_VULKAN
TMultiBlendShader<CTexturedQuadFilter>::IDataBindingFactory*
CTexturedQuadFilter::Initialize(boo::VulkanDataFactory::Context& ctx,
boo::IShaderPipeline*& alphaPipeOut,
boo::IShaderPipeline*& additivePipeOut,
boo::IShaderPipeline*& colorMultiplyPipeOut,
boo::IVertexFormat*& vtxFmtOut)
CTexturedQuadFilter::Initialize(boo::VulkanDataFactory::Context& ctx)
{
const boo::VertexElementDescriptor VtxVmt[] =
{
@ -170,12 +199,12 @@ CTexturedQuadFilter::Initialize(boo::VulkanDataFactory::Context& ctx,
{nullptr, nullptr, boo::VertexSemantic::UV4}
};
vtxFmtOut = ctx.newVertexFormat(2, VtxVmt);
alphaPipeOut = ctx.newShaderPipeline(VSNoFlip, FS, vtxFmtOut, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false);
additivePipeOut = ctx.newShaderPipeline(VSNoFlip, FS, vtxFmtOut, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::One, boo::Primitive::TriStrips, false, false, false);
colorMultiplyPipeOut = ctx.newShaderPipeline(VSNoFlip, FS, vtxFmtOut, boo::BlendFactor::SrcColor,
boo::BlendFactor::DstColor, boo::Primitive::TriStrips, false, false, false);
s_AlphaPipeline = ctx.newShaderPipeline(VSNoFlip, FS, vtxFmtOut, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false);
s_AddPipeline = ctx.newShaderPipeline(VSNoFlip, FS, vtxFmtOut, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::One, boo::Primitive::TriStrips, false, false, false);
s_MultPipeline = ctx.newShaderPipeline(VSNoFlip, FS, vtxFmtOut, boo::BlendFactor::SrcColor,
boo::BlendFactor::DstColor, boo::Primitive::TriStrips, false, false, false);
return new CTexturedQuadFilterVulkanDataBindingFactory;
}
#endif
@ -185,8 +214,7 @@ URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CTexturedQuadFilterAlpha)
struct CTexturedQuadFilterAlphaGLDataBindingFactory : TMultiBlendShader<CTexturedQuadFilterAlpha>::IDataBindingFactory
{
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
boo::IShaderPipeline* pipeline,
boo::IVertexFormat*,
CCameraFilterPass::EFilterType type,
CTexturedQuadFilterAlpha& filter)
{
boo::GLDataFactory::Context& cctx = static_cast<boo::GLDataFactory::Context&>(ctx);
@ -199,7 +227,7 @@ struct CTexturedQuadFilterAlphaGLDataBindingFactory : TMultiBlendShader<CTexture
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf};
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
boo::ITexture* texs[] = {filter.m_booTex};
return cctx.newShaderDataBinding(pipeline,
return cctx.newShaderDataBinding(SelectAlphaPipeline(type),
ctx.newVertexFormat(2, VtxVmt), filter.m_vbo, nullptr, nullptr,
1, bufs, stages, nullptr, nullptr, 1, texs);
}
@ -209,15 +237,14 @@ struct CTexturedQuadFilterAlphaGLDataBindingFactory : TMultiBlendShader<CTexture
struct CTexturedQuadFilterAlphaVulkanDataBindingFactory : TMultiBlendShader<CTexturedQuadFilterAlpha>::IDataBindingFactory
{
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
boo::IShaderPipeline* pipeline,
boo::IVertexFormat* vtxFmt,
CCameraFilterPass::EFilterType type,
CTexturedQuadFilterAlpha& filter)
{
boo::VulkanDataFactory::Context& cctx = static_cast<boo::VulkanDataFactory::Context&>(ctx);
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf};
boo::ITexture* texs[] = {filter.m_booTex};
return cctx.newShaderDataBinding(pipeline, vtxFmt,
return cctx.newShaderDataBinding(SelectAlphaPipeline(type), vtxFmt,
filter.m_vbo, nullptr, nullptr, 1, bufs,
nullptr, nullptr, nullptr, 1, texs);
}
@ -225,29 +252,22 @@ struct CTexturedQuadFilterAlphaVulkanDataBindingFactory : TMultiBlendShader<CTex
#endif
TMultiBlendShader<CTexturedQuadFilterAlpha>::IDataBindingFactory*
CTexturedQuadFilterAlpha::Initialize(boo::GLDataFactory::Context& ctx,
boo::IShaderPipeline*& alphaPipeOut,
boo::IShaderPipeline*& additivePipeOut,
boo::IShaderPipeline*& colorMultiplyPipeOut)
CTexturedQuadFilterAlpha::Initialize(boo::GLDataFactory::Context& ctx)
{
const char* texNames[] = {"tex"};
const char* uniNames[] = {"TexuredQuadUniform"};
alphaPipeOut = ctx.newShaderPipeline(VSFlip, FSAlpha, 1, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false);
additivePipeOut = ctx.newShaderPipeline(VSFlip, FSAlpha, 1, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::One, boo::Primitive::TriStrips, false, false, false);
colorMultiplyPipeOut = ctx.newShaderPipeline(VSFlip, FSAlpha, 1, texNames, 1, uniNames, boo::BlendFactor::SrcColor,
boo::BlendFactor::DstColor, boo::Primitive::TriStrips, false, false, false);
s_AAlphaPipeline = ctx.newShaderPipeline(VSFlip, FSAlpha, 1, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false);
s_AAddPipeline = ctx.newShaderPipeline(VSFlip, FSAlpha, 1, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::One, boo::Primitive::TriStrips, false, false, false);
s_AMultPipeline = ctx.newShaderPipeline(VSFlip, FSAlpha, 1, texNames, 1, uniNames, boo::BlendFactor::SrcColor,
boo::BlendFactor::DstColor, boo::Primitive::TriStrips, false, false, false);
return new CTexturedQuadFilterAlphaGLDataBindingFactory;
}
#if BOO_HAS_VULKAN
TMultiBlendShader<CTexturedQuadFilterAlpha>::IDataBindingFactory*
CTexturedQuadFilterAlpha::Initialize(boo::VulkanDataFactory::Context& ctx,
boo::IShaderPipeline*& alphaPipeOut,
boo::IShaderPipeline*& additivePipeOut,
boo::IShaderPipeline*& colorMultiplyPipeOut,
boo::IVertexFormat*& vtxFmtOut)
CTexturedQuadFilterAlpha::Initialize(boo::VulkanDataFactory::Context& ctx)
{
const boo::VertexElementDescriptor VtxVmt[] =
{
@ -255,12 +275,12 @@ CTexturedQuadFilterAlpha::Initialize(boo::VulkanDataFactory::Context& ctx,
{nullptr, nullptr, boo::VertexSemantic::UV4}
};
vtxFmtOut = ctx.newVertexFormat(2, VtxVmt);
alphaPipeOut = ctx.newShaderPipeline(VSFlip, FSAlpha, vtxFmtOut, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false);
additivePipeOut = ctx.newShaderPipeline(VSFlip, FSAlpha, vtxFmtOut, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::One, boo::Primitive::TriStrips, false, false, false);
colorMultiplyPipeOut = ctx.newShaderPipeline(VSFlip, FSAlpha, vtxFmtOut, boo::BlendFactor::SrcColor,
boo::BlendFactor::DstColor, boo::Primitive::TriStrips, false, false, false);
s_AAlphaPipeline = ctx.newShaderPipeline(VSFlip, FSAlpha, vtxFmtOut, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false);
s_AAddPipeline = ctx.newShaderPipeline(VSFlip, FSAlpha, vtxFmtOut, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::One, boo::Primitive::TriStrips, false, false, false);
s_AMultPipeline = ctx.newShaderPipeline(VSFlip, FSAlpha, vtxFmtOut, boo::BlendFactor::SrcColor,
boo::BlendFactor::DstColor, boo::Primitive::TriStrips, false, false, false);
return new CTexturedQuadFilterAlphaVulkanDataBindingFactory;
}
#endif

View File

@ -103,81 +103,91 @@ static const char* FSAlpha =
URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CTexturedQuadFilter)
static boo::IVertexFormat* s_VtxFmt = nullptr;
static boo::IShaderPipeline* s_AlphaPipeline = nullptr;
static boo::IShaderPipeline* s_AddPipeline = nullptr;
static boo::IShaderPipeline* s_MultPipeline = nullptr;
static boo::IShaderPipeline* SelectPipeline(CCameraFilterPass::EFilterType type)
{
switch (type)
{
case CCameraFilterPass::EFilterType::Blend:
return s_AlphaPipeline;
case CCameraFilterPass::EFilterType::Add:
return s_AddPipeline;
case CCameraFilterPass::EFilterType::Multiply:
return s_MultPipeline;
default:
return nullptr;
}
}
struct CTexturedQuadFilterMetalDataBindingFactory : TMultiBlendShader<CTexturedQuadFilter>::IDataBindingFactory
{
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
boo::IShaderPipeline* pipeline,
boo::IVertexFormat* vtxFmt,
CCameraFilterPass::EFilterType type,
CTexturedQuadFilter& filter)
{
boo::MetalDataFactory::Context& cctx = static_cast<boo::MetalDataFactory::Context&>(ctx);
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf};
boo::ITexture* texs[] = {filter.m_booTex};
return cctx.newShaderDataBinding(pipeline, vtxFmt,
return cctx.newShaderDataBinding(SelectPipeline(type), s_VtxFmt,
filter.m_vbo, nullptr, nullptr, 1, bufs,
nullptr, nullptr, nullptr, 1, texs);
}
};
TMultiBlendShader<CTexturedQuadFilter>::IDataBindingFactory*
CTexturedQuadFilter::Initialize(boo::MetalDataFactory::Context& ctx,
boo::IShaderPipeline*& alphaPipeOut,
boo::IShaderPipeline*& additivePipeOut,
boo::IShaderPipeline*& colorMultiplyPipeOut,
boo::IVertexFormat*& vtxFmtOut)
CTexturedQuadFilter::Initialize(boo::MetalDataFactory::Context& ctx)
{
const boo::VertexElementDescriptor VtxVmt[] =
{
{nullptr, nullptr, boo::VertexSemantic::Position4},
{nullptr, nullptr, boo::VertexSemantic::UV4}
};
vtxFmtOut = ctx.newVertexFormat(2, VtxVmt);
alphaPipeOut = ctx.newShaderPipeline(VSNoFlip, FS, vtxFmtOut, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false);
additivePipeOut = ctx.newShaderPipeline(VSNoFlip, FS, vtxFmtOut, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::One, boo::Primitive::TriStrips, false, false, false);
colorMultiplyPipeOut = ctx.newShaderPipeline(VSNoFlip, FS, vtxFmtOut, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcColor,
boo::BlendFactor::DstColor, boo::Primitive::TriStrips, false, false, false);
s_VtxFmt = ctx.newVertexFormat(2, VtxVmt);
s_AlphaPipeline = ctx.newShaderPipeline(VSNoFlip, FS, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false);
s_AddPipeline = ctx.newShaderPipeline(VSNoFlip, FS, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::One, boo::Primitive::TriStrips, false, false, false);
s_MultPipeline = ctx.newShaderPipeline(VSNoFlip, FS, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcColor,
boo::BlendFactor::DstColor, boo::Primitive::TriStrips, false, false, false);
return new CTexturedQuadFilterMetalDataBindingFactory;
}
struct CTexturedQuadFilterAlphaMetalDataBindingFactory : TMultiBlendShader<CTexturedQuadFilterAlpha>::IDataBindingFactory
{
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
boo::IShaderPipeline* pipeline,
boo::IVertexFormat* vtxFmt,
CCameraFilterPass::EFilterType type,
CTexturedQuadFilterAlpha& filter)
{
boo::MetalDataFactory::Context& cctx = static_cast<boo::MetalDataFactory::Context&>(ctx);
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf};
boo::ITexture* texs[] = {filter.m_booTex};
return cctx.newShaderDataBinding(pipeline, vtxFmt,
return cctx.newShaderDataBinding(SelectPipeline(type), s_VtxFmt,
filter.m_vbo, nullptr, nullptr, 1, bufs,
nullptr, nullptr, nullptr, 1, texs);
}
};
TMultiBlendShader<CTexturedQuadFilterAlpha>::IDataBindingFactory*
CTexturedQuadFilterAlpha::Initialize(boo::MetalDataFactory::Context& ctx,
boo::IShaderPipeline*& alphaPipeOut,
boo::IShaderPipeline*& additivePipeOut,
boo::IShaderPipeline*& colorMultiplyPipeOut,
boo::IVertexFormat*& vtxFmtOut)
CTexturedQuadFilterAlpha::Initialize(boo::MetalDataFactory::Context& ctx)
{
const boo::VertexElementDescriptor VtxVmt[] =
{
{nullptr, nullptr, boo::VertexSemantic::Position4},
{nullptr, nullptr, boo::VertexSemantic::UV4}
};
vtxFmtOut = ctx.newVertexFormat(2, VtxVmt);
alphaPipeOut = ctx.newShaderPipeline(VSFlip, FSAlpha, vtxFmtOut, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false);
additivePipeOut = ctx.newShaderPipeline(VSFlip, FSAlpha, vtxFmtOut, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::One, boo::Primitive::TriStrips, false, false, false);
colorMultiplyPipeOut = ctx.newShaderPipeline(VSFlip, FSAlpha, vtxFmtOut, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcColor,
boo::BlendFactor::DstColor, boo::Primitive::TriStrips, false, false, false);
s_VtxFmt = ctx.newVertexFormat(2, VtxVmt);
s_AlphaPipeline = ctx.newShaderPipeline(VSFlip, FSAlpha, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false);
s_AddPipeline = ctx.newShaderPipeline(VSFlip, FSAlpha, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::One, boo::Primitive::TriStrips, false, false, false);
s_MultPipeline = ctx.newShaderPipeline(VSFlip, FSAlpha, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcColor,
boo::BlendFactor::DstColor, boo::Primitive::TriStrips, false, false, false);
return new CTexturedQuadFilterAlphaMetalDataBindingFactory;
}

View File

@ -66,6 +66,8 @@ void CThermalColdFilter::draw()
CGraphics::g_BooMainCommandQueue->draw(0, 4);
}
void CThermalColdFilter::Shutdown() {}
URDE_SPECIALIZE_SHADER(CThermalColdFilter)
}

View File

@ -75,11 +75,11 @@ BOO_GLSL_BINDING_HEAD
URDE_DECL_SPECIALIZE_SHADER(CThermalColdFilter)
static boo::IShaderPipeline* s_Pipeline = nullptr;
struct CThermalColdFilterGLDataBindingFactory : TShader<CThermalColdFilter>::IDataBindingFactory
{
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
boo::IShaderPipeline* pipeline,
boo::IVertexFormat*,
CThermalColdFilter& filter)
{
boo::GLDataFactory::Context& cctx = static_cast<boo::GLDataFactory::Context&>(ctx);
@ -92,7 +92,7 @@ struct CThermalColdFilterGLDataBindingFactory : TShader<CThermalColdFilter>::IDa
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf};
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
boo::ITexture* texs[] = {CGraphics::g_SpareTexture, filter.m_shiftTex};
return cctx.newShaderDataBinding(pipeline,
return cctx.newShaderDataBinding(s_Pipeline,
ctx.newVertexFormat(2, VtxVmt), filter.m_vbo, nullptr, nullptr,
1, bufs, stages, nullptr, nullptr, 2, texs);
}
@ -102,35 +102,30 @@ struct CThermalColdFilterGLDataBindingFactory : TShader<CThermalColdFilter>::IDa
struct CThermalColdFilterVulkanDataBindingFactory : TShader<CThermalColdFilter>::IDataBindingFactory
{
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
boo::IShaderPipeline* pipeline,
boo::IVertexFormat* vtxFmt,
CThermalColdFilter& filter)
{
boo::VulkanDataFactory::Context& cctx = static_cast<boo::VulkanDataFactory::Context&>(ctx);
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf};
boo::ITexture* texs[] = {CGraphics::g_SpareTexture, filter.m_shiftTex};
return cctx.newShaderDataBinding(pipeline, vtxFmt,
return cctx.newShaderDataBinding(s_Pipeline, vtxFmt,
filter.m_vbo, nullptr, nullptr, 1, bufs,
nullptr, nullptr, nullptr, 2, texs);
}
};
#endif
TShader<CThermalColdFilter>::IDataBindingFactory* CThermalColdFilter::Initialize(boo::GLDataFactory::Context& ctx,
boo::IShaderPipeline*& pipeOut)
TShader<CThermalColdFilter>::IDataBindingFactory* CThermalColdFilter::Initialize(boo::GLDataFactory::Context& ctx)
{
const char* texNames[] = {"sceneTex", "shiftTex"};
const char* uniNames[] = {"ThermalColdUniform"};
pipeOut = ctx.newShaderPipeline(VS, FS, 2, texNames, 1, uniNames, boo::BlendFactor::One,
boo::BlendFactor::Zero, boo::Primitive::TriStrips, false, false, false);
s_Pipeline = ctx.newShaderPipeline(VS, FS, 2, texNames, 1, uniNames, boo::BlendFactor::One,
boo::BlendFactor::Zero, boo::Primitive::TriStrips, false, false, false);
return new CThermalColdFilterGLDataBindingFactory;
}
#if BOO_HAS_VULKAN
TShader<CThermalColdFilter>::IDataBindingFactory* CThermalColdFilter::Initialize(boo::VulkanDataFactory::Context& ctx,
boo::IShaderPipeline*& pipeOut,
boo::IVertexFormat*& vtxFmtOut)
TShader<CThermalColdFilter>::IDataBindingFactory* CThermalColdFilter::Initialize(boo::VulkanDataFactory::Context& ctx)
{
const boo::VertexElementDescriptor VtxVmt[] =
{
@ -138,8 +133,8 @@ TShader<CThermalColdFilter>::IDataBindingFactory* CThermalColdFilter::Initialize
{nullptr, nullptr, boo::VertexSemantic::UV4}
};
vtxFmtOut = ctx.newVertexFormat(2, VtxVmt);
pipeOut = ctx.newShaderPipeline(VS, FS, vtxFmtOut, boo::BlendFactor::One,
boo::BlendFactor::Zero, boo::Primitive::TriStrips, false, false, false);
s_Pipeline = ctx.newShaderPipeline(VS, FS, vtxFmtOut, boo::BlendFactor::One,
boo::BlendFactor::Zero, boo::Primitive::TriStrips, false, false, false);
return new CThermalColdFilterVulkanDataBindingFactory;
}
#endif

View File

@ -85,35 +85,34 @@ static const char* FS =
URDE_DECL_SPECIALIZE_SHADER(CThermalColdFilter)
static boo::IVertexFormat* s_VtxFmt = nullptr;
static boo::IShaderPipeline* s_Pipeline = nullptr;
struct CThermalColdFilterMetalDataBindingFactory : TShader<CThermalColdFilter>::IDataBindingFactory
{
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
boo::IShaderPipeline* pipeline,
boo::IVertexFormat* vtxFmt,
CThermalColdFilter& filter)
{
boo::MetalDataFactory::Context& cctx = static_cast<boo::MetalDataFactory::Context&>(ctx);
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf};
boo::ITexture* texs[] = {CGraphics::g_SpareTexture, filter.m_shiftTex};
return cctx.newShaderDataBinding(pipeline, vtxFmt,
return cctx.newShaderDataBinding(s_Pipeline, s_VtxFmt,
filter.m_vbo, nullptr, nullptr, 1, bufs,
nullptr, nullptr, nullptr, 2, texs);
}
};
TShader<CThermalColdFilter>::IDataBindingFactory* CThermalColdFilter::Initialize(boo::MetalDataFactory::Context& ctx,
boo::IShaderPipeline*& pipeOut,
boo::IVertexFormat*& vtxFmtOut)
TShader<CThermalColdFilter>::IDataBindingFactory* CThermalColdFilter::Initialize(boo::MetalDataFactory::Context& ctx)
{
const boo::VertexElementDescriptor VtxVmt[] =
{
{nullptr, nullptr, boo::VertexSemantic::Position4},
{nullptr, nullptr, boo::VertexSemantic::UV4}
};
vtxFmtOut = ctx.newVertexFormat(2, VtxVmt);
pipeOut = ctx.newShaderPipeline(VS, FS, vtxFmtOut, CGraphics::g_ViewportSamples, boo::BlendFactor::One,
boo::BlendFactor::Zero, boo::Primitive::TriStrips, false, false, false);
s_VtxFmt = ctx.newVertexFormat(2, VtxVmt);
s_Pipeline = ctx.newShaderPipeline(VS, FS, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::One,
boo::BlendFactor::Zero, boo::Primitive::TriStrips, false, false, false);
return new CThermalColdFilterMetalDataBindingFactory;
}

View File

@ -36,6 +36,8 @@ void CThermalHotFilter::draw()
CGraphics::g_BooMainCommandQueue->draw(0, 4);
}
void CThermalHotFilter::Shutdown() {}
URDE_SPECIALIZE_SHADER(CThermalHotFilter)
}

View File

@ -52,11 +52,12 @@ BOO_GLSL_BINDING_HEAD
URDE_DECL_SPECIALIZE_SHADER(CThermalHotFilter)
static boo::IVertexFormat* s_VtxFmt = nullptr;
static boo::IShaderPipeline* s_Pipeline = nullptr;
struct CThermalHotFilterGLDataBindingFactory : TShader<CThermalHotFilter>::IDataBindingFactory
{
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
boo::IShaderPipeline* pipeline,
boo::IVertexFormat*,
CThermalHotFilter& filter)
{
boo::GLDataFactory::Context& cctx = static_cast<boo::GLDataFactory::Context&>(ctx);
@ -69,7 +70,7 @@ struct CThermalHotFilterGLDataBindingFactory : TShader<CThermalHotFilter>::IData
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf};
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
boo::ITexture* texs[] = {CGraphics::g_SpareTexture, g_Renderer->GetThermoPalette()};
return cctx.newShaderDataBinding(pipeline,
return cctx.newShaderDataBinding(s_Pipeline,
ctx.newVertexFormat(2, VtxVmt), filter.m_vbo, nullptr, nullptr,
1, bufs, stages, nullptr, nullptr, 2, texs);
}
@ -79,44 +80,39 @@ struct CThermalHotFilterGLDataBindingFactory : TShader<CThermalHotFilter>::IData
struct CThermalHotFilterVulkanDataBindingFactory : TShader<CThermalHotFilter>::IDataBindingFactory
{
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
boo::IShaderPipeline* pipeline,
boo::IVertexFormat* vtxFmt,
CThermalHotFilter& filter)
{
boo::VulkanDataFactory::Context& cctx = static_cast<boo::VulkanDataFactory::Context&>(ctx);
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf};
boo::ITexture* texs[] = {CGraphics::g_SpareTexture, g_Renderer->GetThermoPalette()};
return cctx.newShaderDataBinding(pipeline, vtxFmt,
return cctx.newShaderDataBinding(s_Pipeline, s_VtxFmt,
filter.m_vbo, nullptr, nullptr, 1, bufs,
nullptr, nullptr, nullptr, 2, texs);
}
};
#endif
TShader<CThermalHotFilter>::IDataBindingFactory* CThermalHotFilter::Initialize(boo::GLDataFactory::Context& ctx,
boo::IShaderPipeline*& pipeOut)
TShader<CThermalHotFilter>::IDataBindingFactory* CThermalHotFilter::Initialize(boo::GLDataFactory::Context& ctx)
{
const char* texNames[] = {"sceneTex", "paletteTex"};
const char* uniNames[] = {"ThermalHotUniform"};
pipeOut = ctx.newShaderPipeline(VS, FS, 2, texNames, 1, uniNames, boo::BlendFactor::DstAlpha,
boo::BlendFactor::InvDstAlpha, boo::Primitive::TriStrips, false, false, false);
s_Pipeline = ctx.newShaderPipeline(VS, FS, 2, texNames, 1, uniNames, boo::BlendFactor::DstAlpha,
boo::BlendFactor::InvDstAlpha, boo::Primitive::TriStrips, false, false, false);
return new CThermalHotFilterGLDataBindingFactory;
}
#if BOO_HAS_VULKAN
TShader<CThermalHotFilter>::IDataBindingFactory* CThermalHotFilter::Initialize(boo::VulkanDataFactory::Context& ctx,
boo::IShaderPipeline*& pipeOut,
boo::IVertexFormat*& vtxFmtOut)
TShader<CThermalHotFilter>::IDataBindingFactory* CThermalHotFilter::Initialize(boo::VulkanDataFactory::Context& ctx)
{
const boo::VertexElementDescriptor VtxVmt[] =
{
{nullptr, nullptr, boo::VertexSemantic::Position4},
{nullptr, nullptr, boo::VertexSemantic::UV4}
};
vtxFmtOut = ctx.newVertexFormat(2, VtxVmt);
pipeOut = ctx.newShaderPipeline(VS, FS, vtxFmtOut, boo::BlendFactor::DstAlpha,
boo::BlendFactor::InvDstAlpha, boo::Primitive::TriStrips, false, false, false);
s_VtxFmt = ctx.newVertexFormat(2, VtxVmt);
s_Pipeline = ctx.newShaderPipeline(VS, FS, s_VtxFmt, boo::BlendFactor::DstAlpha,
boo::BlendFactor::InvDstAlpha, boo::Primitive::TriStrips, false, false, false);
return new CThermalHotFilterVulkanDataBindingFactory;
}
#endif

View File

@ -58,36 +58,35 @@ static const char* FS =
URDE_DECL_SPECIALIZE_SHADER(CThermalHotFilter)
static boo::IVertexFormat* s_VtxFmt = nullptr;
static boo::IShaderPipeline* s_Pipeline = nullptr;
struct CThermalHotFilterMetalDataBindingFactory : TShader<CThermalHotFilter>::IDataBindingFactory
{
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
boo::IShaderPipeline* pipeline,
boo::IVertexFormat* vtxFmt,
CThermalHotFilter& filter)
{
boo::MetalDataFactory::Context& cctx = static_cast<boo::MetalDataFactory::Context&>(ctx);
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf};
boo::ITexture* texs[] = {CGraphics::g_SpareTexture, g_Renderer->GetThermoPalette()};
return cctx.newShaderDataBinding(pipeline, vtxFmt,
return cctx.newShaderDataBinding(s_Pipeline, s_VtxFmt,
filter.m_vbo, nullptr, nullptr, 1, bufs,
nullptr, nullptr, nullptr, 2, texs);
}
};
TShader<CThermalHotFilter>::IDataBindingFactory* CThermalHotFilter::Initialize(boo::MetalDataFactory::Context& ctx,
boo::IShaderPipeline*& pipeOut,
boo::IVertexFormat*& vtxFmtOut)
TShader<CThermalHotFilter>::IDataBindingFactory* CThermalHotFilter::Initialize(boo::MetalDataFactory::Context& ctx)
{
const boo::VertexElementDescriptor VtxVmt[] =
{
{nullptr, nullptr, boo::VertexSemantic::Position4},
{nullptr, nullptr, boo::VertexSemantic::UV4}
};
vtxFmtOut = ctx.newVertexFormat(2, VtxVmt);
pipeOut = ctx.newShaderPipeline(VS, FS, vtxFmtOut, CGraphics::g_ViewportSamples,
boo::BlendFactor::DstAlpha, boo::BlendFactor::InvDstAlpha,
boo::Primitive::TriStrips, false, false, false);
s_VtxFmt = ctx.newVertexFormat(2, VtxVmt);
s_Pipeline = ctx.newShaderPipeline(VS, FS, s_VtxFmt, CGraphics::g_ViewportSamples,
boo::BlendFactor::DstAlpha, boo::BlendFactor::InvDstAlpha,
boo::Primitive::TriStrips, false, false, false);
return new CThermalHotFilterMetalDataBindingFactory;
}

View File

@ -54,6 +54,8 @@ void CXRayBlurFilter::draw(float amount)
CGraphics::g_BooMainCommandQueue->draw(0, 4);
}
void CXRayBlurFilter::Shutdown() {}
URDE_SPECIALIZE_SHADER(CXRayBlurFilter)
}

View File

@ -64,11 +64,12 @@ BOO_GLSL_BINDING_HEAD
URDE_DECL_SPECIALIZE_SHADER(CXRayBlurFilter)
static boo::IVertexFormat* s_VtxFmt = nullptr;
static boo::IShaderPipeline* s_Pipeline = nullptr;
struct CXRayBlurFilterGLDataBindingFactory : TShader<CXRayBlurFilter>::IDataBindingFactory
{
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
boo::IShaderPipeline* pipeline,
boo::IVertexFormat*,
CXRayBlurFilter& filter)
{
boo::GLDataFactory::Context& cctx = static_cast<boo::GLDataFactory::Context&>(ctx);
@ -81,7 +82,7 @@ struct CXRayBlurFilterGLDataBindingFactory : TShader<CXRayBlurFilter>::IDataBind
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf};
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
boo::ITexture* texs[] = {CGraphics::g_SpareTexture, filter.m_booTex};
return cctx.newShaderDataBinding(pipeline,
return cctx.newShaderDataBinding(s_Pipeline,
ctx.newVertexFormat(2, VtxVmt), filter.m_vbo, nullptr, nullptr,
1, bufs, stages, nullptr, nullptr, 2, texs);
}
@ -99,36 +100,33 @@ struct CXRayBlurFilterVulkanDataBindingFactory : TShader<CXRayBlurFilter>::IData
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf};
boo::ITexture* texs[] = {CGraphics::g_SpareTexture, filter.m_booTex};
return cctx.newShaderDataBinding(pipeline, vtxFmt,
return cctx.newShaderDataBinding(s_Pipeline, s_VtxFmt,
filter.m_vbo, nullptr, nullptr, 1, bufs,
nullptr, nullptr, nullptr, 2, texs);
}
};
#endif
TShader<CXRayBlurFilter>::IDataBindingFactory* CXRayBlurFilter::Initialize(boo::GLDataFactory::Context& ctx,
boo::IShaderPipeline*& pipeOut)
TShader<CXRayBlurFilter>::IDataBindingFactory* CXRayBlurFilter::Initialize(boo::GLDataFactory::Context& ctx)
{
const char* texNames[] = {"sceneTex", "paletteTex"};
const char* uniNames[] = {"XRayBlurUniform"};
pipeOut = ctx.newShaderPipeline(VS, FS, 2, texNames, 1, uniNames, boo::BlendFactor::One,
boo::BlendFactor::Zero, boo::Primitive::TriStrips, false, false, false);
s_Pipeline = ctx.newShaderPipeline(VS, FS, 2, texNames, 1, uniNames, boo::BlendFactor::One,
boo::BlendFactor::Zero, boo::Primitive::TriStrips, false, false, false);
return new CXRayBlurFilterGLDataBindingFactory;
}
#if BOO_HAS_VULKAN
TShader<CXRayBlurFilter>::IDataBindingFactory* CXRayBlurFilter::Initialize(boo::VulkanDataFactory::Context& ctx,
boo::IShaderPipeline*& pipeOut,
boo::IVertexFormat*& vtxFmtOut)
TShader<CXRayBlurFilter>::IDataBindingFactory* CXRayBlurFilter::Initialize(boo::VulkanDataFactory::Context& ctx)
{
const boo::VertexElementDescriptor VtxVmt[] =
{
{nullptr, nullptr, boo::VertexSemantic::Position4},
{nullptr, nullptr, boo::VertexSemantic::UV4}
};
vtxFmtOut = ctx.newVertexFormat(2, VtxVmt);
pipeOut = ctx.newShaderPipeline(VS, FS, vtxFmtOut, boo::BlendFactor::One,
boo::BlendFactor::Zero, boo::Primitive::TriStrips, false, false, false);
s_VtxFmt = ctx.newVertexFormat(2, VtxVmt);
s_Pipeline = ctx.newShaderPipeline(VS, FS, s_VtxFmt, boo::BlendFactor::One,
boo::BlendFactor::Zero, boo::Primitive::TriStrips, false, false, false);
return new CXRayBlurFilterVulkanDataBindingFactory;
}
#endif

View File

@ -73,35 +73,34 @@ static const char* FS =
URDE_DECL_SPECIALIZE_SHADER(CXRayBlurFilter)
static boo::IVertexFormat* s_VtxFmt = nullptr;
static boo::IShaderPipeline* s_Pipeline = nullptr;
struct CXRayBlurFilterMetalDataBindingFactory : TShader<CXRayBlurFilter>::IDataBindingFactory
{
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
boo::IShaderPipeline* pipeline,
boo::IVertexFormat* vtxFmt,
CXRayBlurFilter& filter)
{
boo::MetalDataFactory::Context& cctx = static_cast<boo::MetalDataFactory::Context&>(ctx);
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf};
boo::ITexture* texs[] = {CGraphics::g_SpareTexture, filter.m_booTex};
return cctx.newShaderDataBinding(pipeline, vtxFmt,
return cctx.newShaderDataBinding(s_Pipeline, s_VtxFmt,
filter.m_vbo, nullptr, nullptr, 1, bufs,
nullptr, nullptr, nullptr, 2, texs);
}
};
TShader<CXRayBlurFilter>::IDataBindingFactory* CXRayBlurFilter::Initialize(boo::MetalDataFactory::Context& ctx,
boo::IShaderPipeline*& pipeOut,
boo::IVertexFormat*& vtxFmtOut)
TShader<CXRayBlurFilter>::IDataBindingFactory* CXRayBlurFilter::Initialize(boo::MetalDataFactory::Context& ctx)
{
const boo::VertexElementDescriptor VtxVmt[] =
{
{nullptr, nullptr, boo::VertexSemantic::Position4},
{nullptr, nullptr, boo::VertexSemantic::UV4}
};
vtxFmtOut = ctx.newVertexFormat(2, VtxVmt);
pipeOut = ctx.newShaderPipeline(VS, FS, vtxFmtOut, CGraphics::g_ViewportSamples, boo::BlendFactor::One,
boo::BlendFactor::Zero, boo::Primitive::TriStrips, false, false, false);
s_VtxFmt = ctx.newVertexFormat(2, VtxVmt);
s_Pipeline = ctx.newShaderPipeline(VS, FS, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::One,
boo::BlendFactor::Zero, boo::Primitive::TriStrips, false, false, false);
return new CXRayBlurFilterMetalDataBindingFactory;
}

View File

@ -11,23 +11,17 @@
namespace urde
{
template <class FilterImp>
template <class ShaderImp>
class TMultiBlendShader
{
public:
struct IDataBindingFactory
{
virtual boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
boo::IShaderPipeline* pipeline,
boo::IVertexFormat* vtxFmt,
FilterImp& filter)=0;
CCameraFilterPass::EFilterType type,
ShaderImp& filter)=0;
};
static boo::IShaderPipeline* m_alphaBlendPipeline;
static boo::IShaderPipeline* m_additiveAlphaPipeline;
static boo::IShaderPipeline* m_colorMultiplyPipeline;
static boo::IVertexFormat* m_vtxFmt; /* No OpenGL */
static std::unique_ptr<IDataBindingFactory> m_bindFactory;
static boo::GraphicsDataToken m_gfxToken;
@ -42,29 +36,22 @@ public:
switch (ctx.platform())
{
case boo::IGraphicsDataFactory::Platform::OpenGL:
m_bindFactory.reset(FilterImp::Initialize(static_cast<boo::GLDataFactory::Context&>(ctx),
m_alphaBlendPipeline, m_additiveAlphaPipeline, m_colorMultiplyPipeline));
m_bindFactory.reset(ShaderImp::Initialize(static_cast<boo::GLDataFactory::Context&>(ctx)));
break;
#if _WIN32
case boo::IGraphicsDataFactory::Platform::D3D11:
case boo::IGraphicsDataFactory::Platform::D3D12:
m_bindFactory.reset(FilterImp::Initialize(static_cast<boo::ID3DDataFactory::Context&>(ctx),
m_alphaBlendPipeline, m_additiveAlphaPipeline,
m_colorMultiplyPipeline, m_vtxFmt));
m_bindFactory.reset(FilterImp::Initialize(static_cast<boo::ID3DDataFactory::Context&>(ctx)));
break;
#endif
#if BOO_HAS_METAL
case boo::IGraphicsDataFactory::Platform::Metal:
m_bindFactory.reset(FilterImp::Initialize(static_cast<boo::MetalDataFactory::Context&>(ctx),
m_alphaBlendPipeline, m_additiveAlphaPipeline,
m_colorMultiplyPipeline, m_vtxFmt));
m_bindFactory.reset(ShaderImp::Initialize(static_cast<boo::MetalDataFactory::Context&>(ctx)));
break;
#endif
#if BOO_HAS_VULKAN
case boo::IGraphicsDataFactory::Platform::Vulkan:
m_bindFactory.reset(FilterImp::Initialize(static_cast<boo::VulkanDataFactory::Context&>(ctx),
m_alphaBlendPipeline, m_additiveAlphaPipeline,
m_colorMultiplyPipeline, m_vtxFmt));
m_bindFactory.reset(FilterImp::Initialize(static_cast<boo::VulkanDataFactory::Context&>(ctx)));
break;
#endif
default: break;
@ -75,47 +62,25 @@ public:
static void Shutdown()
{
ShaderImp::Shutdown();
m_gfxToken.doDestroy();
}
static boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
CCameraFilterPass::EFilterType type,
FilterImp& filter)
ShaderImp& filter)
{
if (type == CCameraFilterPass::EFilterType::Add)
return m_bindFactory->BuildShaderDataBinding(ctx, m_additiveAlphaPipeline, m_vtxFmt, filter);
else if (type == CCameraFilterPass::EFilterType::Multiply)
return m_bindFactory->BuildShaderDataBinding(ctx, m_colorMultiplyPipeline, m_vtxFmt, filter);
else
return m_bindFactory->BuildShaderDataBinding(ctx, m_alphaBlendPipeline, m_vtxFmt, filter);
return m_bindFactory->BuildShaderDataBinding(ctx, type, filter);
}
};
#define URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(cls) \
template <> boo::IShaderPipeline* \
TMultiBlendShader<cls>::m_alphaBlendPipeline; \
template <> boo::IShaderPipeline* \
TMultiBlendShader<cls>::m_additiveAlphaPipeline; \
template <> boo::IShaderPipeline* \
TMultiBlendShader<cls>::m_colorMultiplyPipeline; \
template <> boo::IVertexFormat* \
TMultiBlendShader<cls>::m_vtxFmt; \
\
template <> std::unique_ptr<TMultiBlendShader<cls>::IDataBindingFactory> \
TMultiBlendShader<cls>::m_bindFactory; \
template <> boo::GraphicsDataToken \
TMultiBlendShader<cls>::m_gfxToken; \
#define URDE_SPECIALIZE_MULTI_BLEND_SHADER(cls) \
template <> boo::IShaderPipeline* \
TMultiBlendShader<cls>::m_alphaBlendPipeline = nullptr; \
template <> boo::IShaderPipeline* \
TMultiBlendShader<cls>::m_additiveAlphaPipeline = nullptr; \
template <> boo::IShaderPipeline* \
TMultiBlendShader<cls>::m_colorMultiplyPipeline = nullptr; \
template <> boo::IVertexFormat* \
TMultiBlendShader<cls>::m_vtxFmt = nullptr; \
\
template <> std::unique_ptr<TMultiBlendShader<cls>::IDataBindingFactory> \
TMultiBlendShader<cls>::m_bindFactory = {}; \
template <> boo::GraphicsDataToken \

View File

@ -1,25 +1,11 @@
static TMultiBlendShader<_CLS>::IDataBindingFactory* Initialize(boo::GLDataFactory::Context& ctx,
boo::IShaderPipeline*& alphaPipeOut,
boo::IShaderPipeline*& additivePipeOut,
boo::IShaderPipeline*& colorMultiplyPipeOut);
static TMultiBlendShader<_CLS>::IDataBindingFactory* Initialize(boo::GLDataFactory::Context& ctx);
#if _WIN32
static TMultiBlendShader<_CLS>::IDataBindingFactory* Initialize(boo::ID3DDataFactory::Context& ctx,
boo::IShaderPipeline*& alphaPipeOut,
boo::IShaderPipeline*& additivePipeOut,
boo::IShaderPipeline*& colorMultiplyPipeOut,
boo::IVertexFormat*& vtxFmtOut);
static TMultiBlendShader<_CLS>::IDataBindingFactory* Initialize(boo::ID3DDataFactory::Context& ctx);
#endif
#if BOO_HAS_METAL
static TMultiBlendShader<_CLS>::IDataBindingFactory* Initialize(boo::MetalDataFactory::Context& ctx,
boo::IShaderPipeline*& alphaPipeOut,
boo::IShaderPipeline*& additivePipeOut,
boo::IShaderPipeline*& colorMultiplyPipeOut,
boo::IVertexFormat*& vtxFmtOut);
static TMultiBlendShader<_CLS>::IDataBindingFactory* Initialize(boo::MetalDataFactory::Context& ctx);
#endif
#if BOO_HAS_VULKAN
static TMultiBlendShader<_CLS>::IDataBindingFactory* Initialize(boo::VulkanDataFactory::Context& ctx,
boo::IShaderPipeline*& alphaPipeOut,
boo::IShaderPipeline*& additivePipeOut,
boo::IShaderPipeline*& colorMultiplyPipeOut,
boo::IVertexFormat*& vtxFmtOut);
static TMultiBlendShader<_CLS>::IDataBindingFactory* Initialize(boo::VulkanDataFactory::Context& ctx);
#endif
static void Shutdown();

View File

@ -10,21 +10,16 @@
namespace urde
{
template <class FilterImp>
template <class ShaderImp>
class TShader
{
public:
struct IDataBindingFactory
{
virtual boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
boo::IShaderPipeline* pipeline,
boo::IVertexFormat* vtxFmt,
FilterImp& filter)=0;
ShaderImp& filter)=0;
};
static boo::IShaderPipeline* m_pipeline;
static boo::IVertexFormat* m_vtxFmt; /* No OpenGL */
static std::unique_ptr<IDataBindingFactory> m_bindFactory;
static boo::GraphicsDataToken m_gfxToken;
@ -39,26 +34,22 @@ public:
switch (ctx.platform())
{
case boo::IGraphicsDataFactory::Platform::OpenGL:
m_bindFactory.reset(FilterImp::Initialize(static_cast<boo::GLDataFactory::Context&>(ctx),
m_pipeline));
m_bindFactory.reset(ShaderImp::Initialize(static_cast<boo::GLDataFactory::Context&>(ctx)));
break;
#if _WIN32
case boo::IGraphicsDataFactory::Platform::D3D11:
case boo::IGraphicsDataFactory::Platform::D3D12:
m_bindFactory.reset(FilterImp::Initialize(static_cast<boo::ID3DDataFactory::Context&>(ctx),
m_pipeline, m_vtxFmt));
m_bindFactory.reset(FilterImp::Initialize(static_cast<boo::ID3DDataFactory::Context&>(ctx)));
break;
#endif
#if BOO_HAS_METAL
case boo::IGraphicsDataFactory::Platform::Metal:
m_bindFactory.reset(FilterImp::Initialize(static_cast<boo::MetalDataFactory::Context&>(ctx),
m_pipeline, m_vtxFmt));
m_bindFactory.reset(ShaderImp::Initialize(static_cast<boo::MetalDataFactory::Context&>(ctx)));
break;
#endif
#if BOO_HAS_VULKAN
case boo::IGraphicsDataFactory::Platform::Vulkan:
m_bindFactory.reset(FilterImp::Initialize(static_cast<boo::VulkanDataFactory::Context&>(ctx),
m_pipeline, m_vtxFmt));
m_bindFactory.reset(FilterImp::Initialize(static_cast<boo::VulkanDataFactory::Context&>(ctx)));
break;
#endif
default: break;
@ -69,32 +60,23 @@ public:
static void Shutdown()
{
ShaderImp::Shutdown();
m_gfxToken.doDestroy();
}
static boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, FilterImp& filter)
static boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, ShaderImp& filter)
{
return m_bindFactory->BuildShaderDataBinding(ctx, m_pipeline, m_vtxFmt, filter);
return m_bindFactory->BuildShaderDataBinding(ctx, filter);
}
};
#define URDE_DECL_SPECIALIZE_SHADER(cls) \
template <> boo::IShaderPipeline* \
TShader<cls>::m_pipeline; \
template <> boo::IVertexFormat* \
TShader<cls>::m_vtxFmt; \
\
template <> std::unique_ptr<TShader<cls>::IDataBindingFactory> \
TShader<cls>::m_bindFactory; \
template <> boo::GraphicsDataToken \
TShader<cls>::m_gfxToken; \
#define URDE_SPECIALIZE_SHADER(cls) \
template <> boo::IShaderPipeline* \
TShader<cls>::m_pipeline = nullptr; \
template <> boo::IVertexFormat* \
TShader<cls>::m_vtxFmt = nullptr; \
\
template <> std::unique_ptr<TShader<cls>::IDataBindingFactory> \
TShader<cls>::m_bindFactory = {}; \
template <> boo::GraphicsDataToken \

View File

@ -1,17 +1,11 @@
static TShader<_CLS>::IDataBindingFactory* Initialize(boo::GLDataFactory::Context& ctx,
boo::IShaderPipeline*& pipeOut);
static TShader<_CLS>::IDataBindingFactory* Initialize(boo::GLDataFactory::Context& ctx);
#if _WIN32
static TShader<_CLS>::IDataBindingFactory* Initialize(boo::ID3DDataFactory::Context& ctx,
boo::IShaderPipeline*& pipeOut,
boo::IVertexFormat*& vtxFmtOut);
static TShader<_CLS>::IDataBindingFactory* Initialize(boo::ID3DDataFactory::Context& ctx);
#endif
#if BOO_HAS_METAL
static TShader<_CLS>::IDataBindingFactory* Initialize(boo::MetalDataFactory::Context& ctx,
boo::IShaderPipeline*& pipeOut,
boo::IVertexFormat*& vtxFmtOut);
static TShader<_CLS>::IDataBindingFactory* Initialize(boo::MetalDataFactory::Context& ctx);
#endif
#if BOO_HAS_VULKAN
static TShader<_CLS>::IDataBindingFactory* Initialize(boo::VulkanDataFactory::Context& ctx,
boo::IShaderPipeline*& pipeOut,
boo::IVertexFormat*& vtxFmtOut);
static TShader<_CLS>::IDataBindingFactory* Initialize(boo::VulkanDataFactory::Context& ctx);
#endif
static void Shutdown();

View File

@ -11,6 +11,7 @@ class CAuiEnergyBarT01 : public CGuiWidget
{
public:
CAuiEnergyBarT01(const CGuiWidgetParms& parms, u32);
FourCC GetWidgetTypeID() const { return FOURCC('ENRG'); }
static std::shared_ptr<CGuiWidget> Create(CGuiFrame* frame, CInputStream& in, CSimplePool* sp);
};

View File

@ -13,6 +13,7 @@ public:
CAuiImagePane(const CGuiWidgetParms& parms, CSimplePool* sp, ResId, ResId,
rstl::reserved_vector<zeus::CVector3f, 4>&& coords,
rstl::reserved_vector<zeus::CVector2f, 4>&& uvs, bool);
FourCC GetWidgetTypeID() const { return FOURCC('IMGP'); }
static std::shared_ptr<CGuiWidget> Create(CGuiFrame* frame, CInputStream& in, CSimplePool* sp);
};
}

View File

@ -19,7 +19,7 @@ class CAuiMeter : public CGuiGroup
public:
CAuiMeter(const CGuiWidgetParms& parms, bool noRoundUp,
u32 maxCapacity, u32 workerCount);
FourCC GetWidgetTypeID() const {return FOURCC('METR');}
FourCC GetWidgetTypeID() const { return FOURCC('METR'); }
void OnVisibleChange();
void SetCurrValue(s32 val);

View File

@ -3,18 +3,19 @@
namespace urde
{
CFontImageDef::CFontImageDef(std::vector<TToken<CTexture>>&& texs,
CFontImageDef::CFontImageDef(const std::vector<TToken<CTexture>>& texs,
float interval, const zeus::CVector2f& vec)
: x0_fps(interval), x4_texs(std::move(texs)), x14_pointsPerTexel(vec)
: x0_fps(interval), x14_pointsPerTexel(vec)
{
for (TToken<CTexture>& tok : x4_texs)
tok.Lock();
x4_texs.reserve(texs.size());
for (const TToken<CTexture>& tok : texs)
x4_texs.push_back(tok);
}
CFontImageDef::CFontImageDef(TToken<CTexture>&& tex, const zeus::CVector2f& vec)
: x0_fps(0.f), x4_texs({std::move(tex)}), x14_pointsPerTexel(vec)
CFontImageDef::CFontImageDef(const TToken<CTexture>& tex, const zeus::CVector2f& vec)
: x0_fps(0.f), x14_pointsPerTexel(vec)
{
x4_texs[0].Lock();
x4_texs.push_back(tex);
}
bool CFontImageDef::IsLoaded() const

View File

@ -13,12 +13,12 @@ class CFontImageDef
{
public:
float x0_fps;
std::vector<TToken<CTexture>> x4_texs;
std::vector<TLockedToken<CTexture>> x4_texs;
zeus::CVector2f x14_pointsPerTexel;
CFontImageDef(std::vector<TToken<CTexture>>&& texs, float fps,
CFontImageDef(const std::vector<TToken<CTexture>>& texs, float fps,
const zeus::CVector2f& vec);
CFontImageDef(TToken<CTexture>&& tex, const zeus::CVector2f& vec);
CFontImageDef(const TToken<CTexture>& tex, const zeus::CVector2f& vec);
bool IsLoaded() const;
};

View File

@ -10,7 +10,7 @@ CGuiCamera::CGuiCamera(const CGuiWidgetParms& parms,
float left, float right,
float top, float bottom,
float znear, float zfar)
: CGuiWidget(parms),
: CGuiWidget(parms), xf8_proj(EProjection::Orthographic),
xfc_left(left), x100_right(right),
x104_top(top), x108_bottom(bottom),
x10c_znear(znear), x110_zfar(zfar)
@ -19,7 +19,7 @@ CGuiCamera::CGuiCamera(const CGuiWidgetParms& parms,
CGuiCamera::CGuiCamera(const CGuiWidgetParms& parms,
float fov, float aspect,
float znear, float zfar)
: CGuiWidget(parms),
: CGuiWidget(parms), xf8_proj(EProjection::Perspective),
xfc_fov(fov), x100_aspect(aspect),
x104_znear(znear), x108_zfar(zfar)
{}

View File

@ -41,6 +41,8 @@ public:
float top, float bottom,
float znear, float zfar);
CGuiCamera(const CGuiWidgetParms& parms, float fov, float aspect, float znear, float zfar);
FourCC GetWidgetTypeID() const { return FOURCC('CAMR'); }
static std::shared_ptr<CGuiWidget> Create(CGuiFrame* frame, CInputStream& in, CSimplePool* sp);
zeus::CVector3f ConvertToScreenSpace(const zeus::CVector3f& vec) const;

View File

@ -13,7 +13,7 @@ void CGuiCompoundWidget::OnVisibleChange()
CGuiWidget* child = static_cast<CGuiWidget*>(GetChildObject());
while (child)
{
child->SetIsVisible(true);
child->SetIsVisible(GetIsVisible());
child = static_cast<CGuiWidget*>(child->GetNextSibling());
}
CGuiWidget::OnVisibleChange();
@ -24,7 +24,7 @@ void CGuiCompoundWidget::OnActiveChange()
CGuiWidget* child = static_cast<CGuiWidget*>(GetChildObject());
while (child)
{
child->SetIsActive(true);
child->SetIsActive(GetIsActive());
child = static_cast<CGuiWidget*>(child->GetNextSibling());
}
CGuiWidget::OnActiveChange();

View File

@ -110,20 +110,18 @@ void CGuiFrame::Update(float dt)
void CGuiFrame::Draw(const CGuiWidgetDrawParms& parms) const
{
if (x4_)
{
CGraphics::SetCullMode(ERglCullMode::None);
CGraphics::SetAmbientColor(zeus::CColor::skWhite);
DisableLights();
x14_camera->Draw(parms);
// Set one-stage modulate
CGraphics::SetBlendMode(ERglBlendMode::Blend, ERglBlendFactor::SrcAlpha,
ERglBlendFactor::InvSrcAlpha, ERglLogicOp::Clear);
CGraphics::SetCullMode(ERglCullMode::None);
CGraphics::SetAmbientColor(zeus::CColor::skWhite);
DisableLights();
x14_camera->Draw(parms);
// Set one-stage modulate
CGraphics::SetBlendMode(ERglBlendMode::Blend, ERglBlendFactor::SrcAlpha,
ERglBlendFactor::InvSrcAlpha, ERglLogicOp::Clear);
for (const auto& widget : x2c_widgets)
if (widget->GetIsVisible())
widget->Draw(parms);
for (const auto& widget : x2c_widgets)
if (widget->GetIsVisible())
widget->Draw(parms);
}
CGraphics::SetCullMode(ERglCullMode::Front);
}
@ -160,7 +158,7 @@ void CGuiFrame::LoadWidgetsInGame(CInputStream& in, CSimplePool* sp)
void CGuiFrame::ProcessUserInput(const CFinalInput& input) const
{
if (x4_)
if (input.ControllerIdx() != 0)
return;
for (auto& widget : x2c_widgets)
{

View File

@ -2,6 +2,7 @@
#define __URDE_CGUIFRAME_HPP__
#include "CGuiWidget.hpp"
#include "CGuiHeadWidget.hpp"
#include "CGuiWidgetIdDB.hpp"
#include "IObj.hpp"
@ -10,7 +11,6 @@ namespace urde
class CGuiSys;
class CLight;
class CGuiCamera;
class CGuiHeadWidget;
class CFinalInput;
class CGuiLight;
class CVParamTransfer;
@ -44,6 +44,7 @@ public:
CGuiWidget* FindWidget(s16 id) const;
void SetFrameCamera(std::shared_ptr<CGuiCamera>&& camr) { x14_camera = std::move(camr); }
void SetHeadWidget(std::shared_ptr<CGuiHeadWidget>&& hwig) { xc_headWidget = std::move(hwig); }
CGuiHeadWidget* GetHeadWidget() const { return xc_headWidget.get(); }
void SortDrawOrder();
void EnableLights(u32 lights) const;
void DisableLights() const;

View File

@ -13,7 +13,7 @@ class CGuiGroup : public CGuiCompoundWidget
bool xc0_b;
public:
CGuiGroup(const CGuiWidgetParms& parms, int defaultWorker, bool b);
FourCC GetWidgetTypeID() const {return FOURCC('GRUP');}
FourCC GetWidgetTypeID() const { return FOURCC('GRUP'); }
void SelectWorkerWidget(int workerId, bool setActive, bool setVisible);
CGuiWidget* GetSelectedWidget();

View File

@ -9,7 +9,7 @@ namespace urde
class CGuiHeadWidget : public CGuiWidget
{
public:
FourCC GetWidgetTypeID() const {return FOURCC('HWIG');}
FourCC GetWidgetTypeID() const { return FOURCC('HWIG'); }
CGuiHeadWidget(const CGuiWidgetParms& parms);
static std::shared_ptr<CGuiWidget> Create(CGuiFrame* frame, CInputStream& in, CSimplePool* sp);

View File

@ -23,7 +23,7 @@ class CGuiLight : public CGuiWidget
public:
~CGuiLight();
CGuiLight(const CGuiWidgetParms& parms, const CLight& light);
FourCC GetWidgetTypeID() const {return FOURCC('LITE');}
FourCC GetWidgetTypeID() const { return FOURCC('LITE'); }
CLight BuildLight() const;
void SetIsVisible(bool vis);

View File

@ -16,7 +16,7 @@ class CGuiModel : public CGuiWidget
u32 x10c_lightMask;
public:
CGuiModel(const CGuiWidgetParms& parms, CSimplePool* sp, ResId modelId, u32 lightMask, bool flag);
FourCC GetWidgetTypeID() const {return FOURCC('MODL');}
FourCC GetWidgetTypeID() const { return FOURCC('MODL'); }
std::vector<ResId> GetModelAssets() const;
bool GetIsFinishedLoadingWidgetSpecific() const;

View File

@ -20,7 +20,7 @@ protected:
public:
CGuiPane(const CGuiWidgetParms& parms, const zeus::CVector2f& dim, const zeus::CVector3f& scaleCenter);
FourCC GetWidgetTypeID() const {return FOURCC('PANE');}
FourCC GetWidgetTypeID() const { return FOURCC('PANE'); }
virtual void ScaleDimensions(const zeus::CVector3f& scale);
virtual void SetDimensions(const zeus::CVector2f& dim, bool initVBO);

View File

@ -40,7 +40,7 @@ private:
public:
CGuiSliderGroup(const CGuiWidgetParms& parms, float a, float b, float c, float d);
FourCC GetWidgetTypeID() const {return FOURCC('SLGP');}
FourCC GetWidgetTypeID() const { return FOURCC('SLGP'); }
EState GetState() const { return xf0_state; }
void SetSelectionChangedCallback(std::function<void(CGuiSliderGroup*, float)>&& func);

View File

@ -55,7 +55,7 @@ private:
public:
CGuiTableGroup(const CGuiWidgetParms& parms, int, int, bool);
FourCC GetWidgetTypeID() const {return FOURCC('TBGP');}
FourCC GetWidgetTypeID() const { return FOURCC('TBGP'); }
void SetMenuAdvanceCallback(std::function<void(CGuiTableGroup*)>&& cb)
{

View File

@ -14,7 +14,7 @@ CGuiTextPane::CGuiTextPane(const CGuiWidgetParms& parms, CSimplePool* sp, const
const zeus::CColor& fontCol, const zeus::CColor& outlineCol,
s32 extentX, s32 extentY)
: CGuiPane(parms, dim, vec), xd4_textSupport(fontId, props, fontCol, outlineCol,
zeus::CColor::skWhite, extentX, extentY, sp) {}
zeus::CColor::skWhite, extentX, extentY, sp, xac_drawFlags) {}
void CGuiTextPane::Update(float dt)
{
@ -64,6 +64,7 @@ void CGuiTextPane::Draw(const CGuiWidgetDrawParms& parms) const
geomCol.a *= parms.x0_alphaMod;
const_cast<CGuiTextPane*>(this)->xd4_textSupport.SetGeometryColor(geomCol);
# if 0
CGraphics::SetDepthWriteMode(xb6_31_depthTest, ERglEnum::LEqual, xb7_24_depthWrite);
switch (xac_drawFlags)
@ -95,6 +96,9 @@ void CGuiTextPane::Draw(const CGuiWidgetDrawParms& parms) const
xd4_textSupport.Render();
break;
}
#else
xd4_textSupport.Render();
#endif
}
std::shared_ptr<CGuiWidget> CGuiTextPane::Create(CGuiFrame* frame, CInputStream& in, CSimplePool* sp)

View File

@ -14,13 +14,13 @@ public:
CGuiTextPane(const CGuiWidgetParms& parms, CSimplePool* sp, const zeus::CVector2f& dim,
const zeus::CVector3f& vec, ResId fontId, const CGuiTextProperties& props,
const zeus::CColor& col1, const zeus::CColor& col2, s32 padX, s32 padY);
FourCC GetWidgetTypeID() const {return FOURCC('TXPN');}
FourCC GetWidgetTypeID() const { return FOURCC('TXPN'); }
CGuiTextSupport* TextSupport() {return &xd4_textSupport;}
const CGuiTextSupport* GetTextSupport() const {return &xd4_textSupport;}
CGuiTextSupport* TextSupport() { return &xd4_textSupport; }
const CGuiTextSupport* GetTextSupport() const { return &xd4_textSupport; }
void Update(float dt);
bool GetIsFinishedLoadingWidgetSpecific() const;
std::vector<ResId> GetFontAssets() const {return {xd4_textSupport.x5c_fontId};}
std::vector<ResId> GetFontAssets() const { return {xd4_textSupport.x5c_fontId}; }
void SetDimensions(const zeus::CVector2f& dim, bool initVBO);
void ScaleDimensions(const zeus::CVector3f& scale);
void Draw(const CGuiWidgetDrawParms& parms) const;

View File

@ -13,9 +13,11 @@ namespace urde
CGuiTextSupport::CGuiTextSupport(ResId fontId, const CGuiTextProperties& props,
const zeus::CColor& fontCol, const zeus::CColor& outlineCol,
const zeus::CColor& geomCol, s32 padX, s32 padY, CSimplePool* store)
const zeus::CColor& geomCol, s32 padX, s32 padY, CSimplePool* store,
CGuiWidget::EGuiModelDrawFlags drawFlags)
: x14_props(props), x24_fontColor(fontCol), x28_outlineColor(outlineCol),
x2c_geometryColor(geomCol), x34_extentX(padX), x38_extentY(padY), x5c_fontId(fontId)
x2c_geometryColor(geomCol), x34_extentX(padX), x38_extentY(padY), x5c_fontId(fontId),
m_drawFlags(drawFlags)
{
x2cc_font = store->GetObj({SBIG('FONT'), fontId});
}
@ -138,7 +140,6 @@ void CGuiTextSupport::ClearRenderBuffer()
void CGuiTextSupport::CheckAndRebuildTextBuffer()
{
#if 0
g_TextExecuteBuf->Clear();
g_TextExecuteBuf->x18_textState.x7c_enableWordWrap = x14_props.x0_wordWrap;
g_TextExecuteBuf->BeginBlock(0, 0, x34_extentX, x38_extentY, x14_props.xc_direction,
@ -154,7 +155,6 @@ void CGuiTextSupport::CheckAndRebuildTextBuffer()
g_TextParser->ParseText(*g_TextExecuteBuf, initStr.c_str(), initStr.size());
g_TextExecuteBuf->EndBlock();
#endif
}
bool CGuiTextSupport::CheckAndRebuildRenderBuffer()
@ -173,11 +173,11 @@ bool CGuiTextSupport::CheckAndRebuildRenderBuffer()
if (x308_multipageFlag)
{
zeus::CVector2i extent(x34_extentX, x38_extentY);
x2ec_renderBufferPages = g_TextExecuteBuf->BuildRenderBufferPages(extent);
x2ec_renderBufferPages = g_TextExecuteBuf->BuildRenderBufferPages(extent, m_drawFlags);
}
else
{
x60_renderBuf.emplace(g_TextExecuteBuf->BuildRenderBuffer());
x60_renderBuf.emplace(g_TextExecuteBuf->BuildRenderBuffer(m_drawFlags));
x2dc_oneBufBounds = x60_renderBuf->AccumulateTextBounds();
}
g_TextExecuteBuf->Clear();
@ -201,6 +201,7 @@ void CGuiTextSupport::AutoSetExtent()
void CGuiTextSupport::Render() const
{
const_cast<CGuiTextSupport*>(this)->CheckAndRebuildRenderBuffer();
if (CTextRenderBuffer* buf = GetCurrentPageRenderBuffer())
{
zeus::CTransform oldModel = CGraphics::g_GXModelMatrix;

View File

@ -5,6 +5,7 @@
#include "RetroTypes.hpp"
#include "CToken.hpp"
#include "CTextRenderBuffer.hpp"
#include "CGuiWidget.hpp"
#include "optional.hpp"
#include <string>
@ -91,6 +92,7 @@ class CGuiTextSupport
float x54_chFadeTime = 0.1f;
float x58_chRate = 10.0f;
ResId x5c_fontId = -1;
CGuiWidget::EGuiModelDrawFlags m_drawFlags;
std::experimental::optional<CTextRenderBuffer> x60_renderBuf;
std::vector<CToken> x2bc_assets;
TLockedToken<CRasterFont> x2cc_font;
@ -107,7 +109,8 @@ class CGuiTextSupport
public:
CGuiTextSupport(ResId fontId, const CGuiTextProperties& props,
const zeus::CColor& fontCol, const zeus::CColor& outlineCol,
const zeus::CColor& geomCol, s32 extX, s32 extY, CSimplePool* store);
const zeus::CColor& geomCol, s32 extX, s32 extY, CSimplePool* store,
CGuiWidget::EGuiModelDrawFlags drawFlags);
float GetCurrentAnimationOverAge() const;
float GetNumCharsTotal() const;
float GetNumCharsPrinted() const;

View File

@ -101,7 +101,7 @@ public:
virtual void Touch() const;
virtual bool GetIsVisible() const;
virtual bool GetIsActive() const;
virtual FourCC GetWidgetTypeID() const {return FOURCC('BWIG');}
virtual FourCC GetWidgetTypeID() const { return FOURCC('BWIG'); }
virtual bool AddWorkerWidget(CGuiWidget* worker);
virtual bool GetIsFinishedLoadingWidgetSpecific() const;
virtual void OnVisibleChange();

View File

@ -238,7 +238,7 @@ void CImageInstruction::Invoke(CFontRenderState& state, CTextRenderBuffer* buf)
tex->GetHeight() * x4_image.x14_pointsPerTexel.y * 2 / 3);
buf->AddImage(coords, x4_image);
}
state.xd4_curX += tex->GetWidth() * x4_image.x14_pointsPerTexel.x;
state.xd4_curX = state.xd4_curX + tex->GetWidth() * x4_image.x14_pointsPerTexel.x;
}
}
}

View File

@ -92,7 +92,7 @@ void CRasterFont::SinglePassDrawString(const CDrawStringOptions& opts, int x, in
{
if (opts.x0_direction == ETextDirection::Horizontal)
{
x += glyph->GetA();
x += glyph->GetLeftPadding();
if (prevGlyph != 0)
x += KernLookup(x1c_kerning, prevGlyph->GetKernStart(), *chr);
@ -102,10 +102,10 @@ void CRasterFont::SinglePassDrawString(const CDrawStringOptions& opts, int x, in
if (renderBuf)
{
left += x;
top += glyph->GetBaseline() - y;
top += y - glyph->GetBaseline();
renderBuf->AddCharacter(zeus::CVector2i(left, top), *chr, opts.x4_colors[0]);
}
x += glyph->GetC() + glyph->GetB();
x += glyph->GetRightPadding() + glyph->GetAdvance();
}
}
prevGlyph = glyph;
@ -113,7 +113,7 @@ void CRasterFont::SinglePassDrawString(const CDrawStringOptions& opts, int x, in
if (length == -1)
continue;
if ((str - chr) >= length)
if ((chr - str) >= length)
break;
}
@ -173,8 +173,8 @@ void CRasterFont::GetSize(const CDrawStringOptions& opts, int& width, int& heigh
if (prevGlyph)
advance = KernLookup(x1c_kerning, prevGlyph->GetKernStart(), *chr);
s16 curWidth = prevWidth - (glyph->GetA() + glyph->GetB() + glyph->GetC() + advance);
s16 curHeight = glyph->GetBaseline() - (x8_monoHeight + glyph->GetCellHeight());
int curWidth = prevWidth + (glyph->GetLeftPadding() + glyph->GetAdvance() + glyph->GetRightPadding() + advance);
int curHeight = glyph->GetBaseline() - (x8_monoHeight + glyph->GetCellHeight());
width = curWidth;
prevWidth = curWidth;
@ -189,7 +189,7 @@ void CRasterFont::GetSize(const CDrawStringOptions& opts, int& width, int& heigh
if (len == -1)
continue;
if ((str - chr) >= len)
if ((chr - str) >= len)
break;
}
}

View File

@ -5,11 +5,11 @@
#include "CToken.hpp"
#include "zeus/CVector2i.hpp"
#include "CGuiTextSupport.hpp"
#include "Graphics/CTexture.hpp"
namespace urde
{
class IObjectStore;
class CTexture;
class CDrawStringOptions;
class CTextRenderBuffer;
@ -28,28 +28,30 @@ private:
s16 x1a_cellHeight;
s16 x1c_baseline;
s16 x1e_kernStart;
s16 m_layer;
public:
CGlyph() = default;
CGlyph(s16 a, s16 b, s32 c, float startU, float startV, float endU, float endV,
s16 cellWidth, s16 cellHeight, s16 baseline, s16 kernStart)
s16 cellWidth, s16 cellHeight, s16 baseline, s16 kernStart, s16 layer=0)
: x0_leftPadding(a), x2_advance(b), x4_rightPadding(c),
x8_startU(startU), xc_startV(startV), x10_endU(endU), x14_endV(endV),
x18_cellWidth(cellWidth), x1a_cellHeight(cellHeight),
x1c_baseline(baseline), x1e_kernStart(kernStart)
x1c_baseline(baseline), x1e_kernStart(kernStart), m_layer(layer)
{}
s16 GetA() const { return x0_leftPadding; }
s16 GetB() const { return x2_advance; }
s16 GetC() const { return x4_rightPadding; }
float GetStartU() const { return x8_startU; }
float GetStartV() const { return xc_startV; }
float GetEndU() const { return x10_endU; }
float GetEndV() const { return x14_endV; }
s16 GetCellWidth() const { return x18_cellWidth; }
s16 GetCellHeight() const { return x1a_cellHeight; }
s16 GetBaseline() const { return x1c_baseline; }
s16 GetKernStart() const { return x1e_kernStart; }
s16 GetLeftPadding() const { return x0_leftPadding; }
s16 GetAdvance() const { return x2_advance; }
s16 GetRightPadding() const { return x4_rightPadding; }
float GetStartU() const { return x8_startU; }
float GetStartV() const { return xc_startV; }
float GetEndU() const { return x10_endU; }
float GetEndV() const { return x14_endV; }
s16 GetCellWidth() const { return x18_cellWidth; }
s16 GetCellHeight() const { return x1a_cellHeight; }
s16 GetBaseline() const { return x1c_baseline; }
s16 GetKernStart() const { return x1e_kernStart; }
s16 GetLayer() const { return m_layer; }
};
class CKernPair
@ -146,7 +148,7 @@ public:
}
void GetSize(const CDrawStringOptions& opts, int& width, int& height,
const char16_t* str, int len) const;
TToken<CTexture>& GetTexture() { return x80_texture; }
boo::ITexture* GetTexture() { return x80_texture->GetFontTexture(CTexture::EFontType(x2c_mode)); }
};
std::unique_ptr<IObj> FRasterFontFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& vparms,

View File

@ -11,9 +11,9 @@
namespace urde
{
CTextRenderBuffer CTextExecuteBuffer::BuildRenderBuffer() const
CTextRenderBuffer CTextExecuteBuffer::BuildRenderBuffer(CGuiWidget::EGuiModelDrawFlags df) const
{
CTextRenderBuffer ret(CTextRenderBuffer::EMode::AllocTally);
CTextRenderBuffer ret(CTextRenderBuffer::EMode::AllocTally, df);
{
CFontRenderState rendState;
@ -34,9 +34,10 @@ CTextRenderBuffer CTextExecuteBuffer::BuildRenderBuffer() const
CTextRenderBuffer CTextExecuteBuffer::BuildRenderBufferPage(InstList::const_iterator start,
InstList::const_iterator pgStart,
InstList::const_iterator pgEnd) const
InstList::const_iterator pgEnd,
CGuiWidget::EGuiModelDrawFlags df) const
{
CTextRenderBuffer ret(CTextRenderBuffer::EMode::AllocTally);
CTextRenderBuffer ret(CTextRenderBuffer::EMode::AllocTally, df);
{
CFontRenderState rendState;
@ -71,14 +72,15 @@ CTextRenderBuffer CTextExecuteBuffer::BuildRenderBufferPage(InstList::const_iter
return ret;
}
std::list<CTextRenderBuffer> CTextExecuteBuffer::BuildRenderBufferPages(const zeus::CVector2i& extent) const
std::list<CTextRenderBuffer> CTextExecuteBuffer::BuildRenderBufferPages(const zeus::CVector2i& extent,
CGuiWidget::EGuiModelDrawFlags df) const
{
std::list<CTextRenderBuffer> ret;
for (auto it = x0_instList.begin() ; it != x0_instList.end() ;)
{
const std::shared_ptr<CInstruction>& inst = *it;
CTextRenderBuffer rbuf(CTextRenderBuffer::EMode::AllocTally);
CTextRenderBuffer rbuf(CTextRenderBuffer::EMode::AllocTally, df);
{
CFontRenderState rstate;
@ -111,7 +113,7 @@ std::list<CTextRenderBuffer> CTextExecuteBuffer::BuildRenderBufferPages(const ze
}
}
ret.push_back(BuildRenderBufferPage(x0_instList.cbegin(), it, pageEnd));
ret.push_back(BuildRenderBufferPage(x0_instList.cbegin(), it, pageEnd, df));
it = pageEnd;
}

View File

@ -24,7 +24,7 @@ class CTextExecuteBuffer
CSaveableState x18_textState;
CBlockInstruction* xa0_curBlock = nullptr;
CLineInstruction* xa4_curLine = nullptr;
std::list<std::shared_ptr<CInstruction>>::iterator xa8_curWordIt;
InstList::iterator xa8_curWordIt;
s32 xac_curY;
s32 xb0_curX;
s32 xb4_curWordX = 0;
@ -40,11 +40,13 @@ public:
xa8_curWordIt = x0_instList.begin();
}
CTextRenderBuffer BuildRenderBuffer() const;
CTextRenderBuffer BuildRenderBuffer(CGuiWidget::EGuiModelDrawFlags df) const;
CTextRenderBuffer BuildRenderBufferPage(InstList::const_iterator start,
InstList::const_iterator pgStart,
InstList::const_iterator pgEnd) const;
std::list<CTextRenderBuffer> BuildRenderBufferPages(const zeus::CVector2i& extent) const;
InstList::const_iterator pgEnd,
CGuiWidget::EGuiModelDrawFlags df) const;
std::list<CTextRenderBuffer> BuildRenderBufferPages(const zeus::CVector2i& extent,
CGuiWidget::EGuiModelDrawFlags df) const;
std::vector<CToken> GetAssets() const;
void AddString(const char16_t* str, int len);
void AddStringFragment(const char16_t* str, int len);

View File

@ -240,7 +240,7 @@ CFontImageDef CTextParser::GetImage(const char16_t* str, int len)
AdvanceTokenPos();
} while (commaPos != iterable.size());
return CFontImageDef(std::move(texs), interval, zeus::CVector2f(1.f, 1.f));
return CFontImageDef(texs, interval, zeus::CVector2f(1.f, 1.f));
}
else if (BeginsWith(str, len, u"SA"))
{
@ -267,7 +267,7 @@ CFontImageDef CTextParser::GetImage(const char16_t* str, int len)
AdvanceTokenPos();
} while (commaPos != iterable.size());
return CFontImageDef(std::move(texs), interval, zeus::CVector2f(scaleX, scaleY));
return CFontImageDef(texs, interval, zeus::CVector2f(scaleX, scaleY));
}
else if (BeginsWith(str, len, u"SI"))
{
@ -285,12 +285,12 @@ CFontImageDef CTextParser::GetImage(const char16_t* str, int len)
GetAssetIdFromString(&iterable[tokenPos])});
AdvanceTokenPos();
return CFontImageDef(std::move(tex), zeus::CVector2f(scaleX, scaleY));
return CFontImageDef(tex, zeus::CVector2f(scaleX, scaleY));
}
}
TToken<CTexture> tex = x0_store.GetObj({SBIG('TXTR'), GetAssetIdFromString(str)});
return CFontImageDef(std::move(tex), zeus::CVector2f(1.f, 1.f));
return CFontImageDef(tex, zeus::CVector2f(1.f, 1.f));
}
ResId CTextParser::GetAssetIdFromString(const char16_t* str)
@ -309,7 +309,8 @@ TToken<CRasterFont> CTextParser::GetFont(const char16_t* str, int len)
void CTextParser::ParseText(CTextExecuteBuffer& out, const char16_t* str, int len)
{
for (int b=0, e=0 ; str[e] && (len == -1 || e < len) ;)
int b=0, e=0;
for (b=0, e=0 ; str[e] && (len == -1 || e < len) ;)
{
if (str[e] != u'&')
{
@ -335,6 +336,9 @@ void CTextParser::ParseText(CTextExecuteBuffer& out, const char16_t* str, int le
b = e;
}
}
if (e > b)
out.AddString(str + b, e - b);
}
}

View File

@ -7,34 +7,13 @@
#include "CTextExecuteBuffer.hpp"
#include "CFontRenderState.hpp"
#include "CInstruction.hpp"
#include "Graphics/Shaders/CTextSupportShader.hpp"
namespace urde
{
boo::IShaderPipeline* g_TextShaderPipeline = nullptr;
boo::IVertexFormat* g_TextVtxFmt = nullptr;
boo::IShaderPipeline* g_TextImageShaderPipeline = nullptr;
boo::IVertexFormat* g_TextImageVtxFmt = nullptr;
CTextRenderBuffer::CTextRenderBuffer(EMode mode)
: x0_mode(mode) {}
void CTextRenderBuffer::BooCharacterInstance::SetMetrics(const CGlyph& glyph,
const zeus::CVector2i& offset)
{
m_pos[0].assign(offset.x, 0.f, offset.y);
m_uv[0].assign(glyph.GetStartU(), glyph.GetStartV());
m_pos[1].assign(offset.x + glyph.GetCellWidth(), 0.f, offset.y);
m_uv[1].assign(glyph.GetEndU(), glyph.GetStartV());
m_pos[2].assign(offset.x, 0.f, offset.y + glyph.GetCellHeight());
m_uv[2].assign(glyph.GetStartU(), glyph.GetEndV());
m_pos[3].assign(offset.x + glyph.GetCellWidth(), 0.f, offset.y + glyph.GetCellHeight());
m_uv[3].assign(glyph.GetEndU(), glyph.GetEndV());
}
CTextRenderBuffer::CTextRenderBuffer(EMode mode, CGuiWidget::EGuiModelDrawFlags df)
: x0_mode(mode), m_drawFlags(df) {}
CTextRenderBuffer::BooImage::BooImage(const CFontImageDef& imgDef, const zeus::CVector2i& offset)
: m_imageDef(imgDef)
@ -47,17 +26,7 @@ CTextRenderBuffer::BooImage::BooImage(const CFontImageDef& imgDef, const zeus::C
tex.GetHeight() * imgDef.x14_pointsPerTexel.y);
}
m_imageData.m_pos[0].assign(offset.x, 0.f, offset.y);
m_imageData.m_uv[0].assign(0.f, 0.f);
m_imageData.m_pos[1].assign(offset.x + imgSize.x, 0.f, offset.y);
m_imageData.m_uv[1].assign(1.f, 0.f);
m_imageData.m_pos[2].assign(offset.x, 0.f, offset.y + imgSize.y);
m_imageData.m_uv[2].assign(0.f, 1.f);
m_imageData.m_pos[3].assign(offset.x + imgSize.x, 0.f, offset.y + imgSize.y);
m_imageData.m_uv[3].assign(1.f, 1.f);
m_imageData.SetMetrics(imgSize, offset);
}
void CTextRenderBuffer::BooPrimitiveMark::SetOpacity(CTextRenderBuffer& rb, float opacity)
@ -67,7 +36,7 @@ void CTextRenderBuffer::BooPrimitiveMark::SetOpacity(CTextRenderBuffer& rb, floa
case Command::CharacterRender:
{
BooFontCharacters& fc = rb.m_fontCharacters[m_bindIdx];
BooCharacterInstance& inst = fc.m_charData[m_instIdx];
CTextSupportShader::CharacterInstance& inst = fc.m_charData[m_instIdx];
inst.m_fontColor.a = opacity;
inst.m_outlineColor.a = opacity;
fc.m_dirty = true;
@ -90,70 +59,87 @@ void CTextRenderBuffer::CommitResources()
return;
m_committed = true;
/* Ensure font textures are ready outside transaction */
for (BooFontCharacters& chs : m_fontCharacters)
chs.m_font->GetTexture();
m_booToken = CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(BooUniform), 1);
m_uniBuf = CTextSupportShader::s_Uniforms.allocateBlock(CGraphics::g_BooFactory);
auto uBufInfo = m_uniBuf.getBufferInfo();
for (BooFontCharacters& chs : m_fontCharacters)
{
chs.m_instBuf = ctx.newDynamicBuffer(boo::BufferUse::Vertex,
sizeof(BooCharacterInstance),
chs.m_charCount);
boo::IVertexFormat* vFmt = g_TextVtxFmt;
chs.m_instBuf = CTextSupportShader::s_CharInsts.allocateBlock(CGraphics::g_BooFactory, chs.m_charCount);
auto iBufInfo = chs.m_instBuf.getBufferInfo();
boo::IVertexFormat* vFmt = CTextSupportShader::s_TextVtxFmt;
if (ctx.bindingNeedsVertexFormat())
{
boo::IGraphicsBufferD* buf = iBufInfo.first;
boo::VertexElementDescriptor elems[] =
{
{chs.m_instBuf, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 0},
{chs.m_instBuf, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 1},
{chs.m_instBuf, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 2},
{chs.m_instBuf, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 3},
{chs.m_instBuf, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 0},
{chs.m_instBuf, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 1},
{chs.m_instBuf, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 2},
{chs.m_instBuf, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 3},
{chs.m_instBuf, nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced, 0},
{chs.m_instBuf, nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced, 1},
{buf, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 0},
{buf, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 1},
{buf, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 2},
{buf, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 3},
{buf, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 0},
{buf, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 1},
{buf, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 2},
{buf, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 3},
{buf, nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced, 0},
{buf, nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced, 1},
};
vFmt = ctx.newVertexFormat(10, elems);
vFmt = ctx.newVertexFormat(10, elems, 0, iBufInfo.second);
}
boo::IGraphicsBuffer* uniforms[] = {m_uniBuf};
boo::ITexture* texs[] = {chs.m_font.GetObj()->GetTexture()->GetBooTexture()};
chs.m_dataBinding = ctx.newShaderDataBinding(g_TextShaderPipeline, vFmt,
nullptr, chs.m_instBuf, nullptr,
1, uniforms, nullptr, 1, texs);
boo::IGraphicsBuffer* uniforms[] = {uBufInfo.first};
boo::PipelineStage unistages[] = {boo::PipelineStage::Vertex};
size_t unioffs[] = {uBufInfo.second};
size_t unisizes[] = {sizeof(CTextSupportShader::Uniform)};
boo::ITexture* texs[] = {chs.m_font->GetTexture()};
chs.m_dataBinding = ctx.newShaderDataBinding(CTextSupportShader::SelectTextPipeline(m_drawFlags),
vFmt, nullptr, iBufInfo.first, nullptr,
1, uniforms, unistages, unioffs,
unisizes, 1, texs, 0, iBufInfo.second);
}
for (BooImage& img : m_images)
{
img.m_instBuf = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(BooImageInstance), 1);
boo::IVertexFormat* vFmt = g_TextImageVtxFmt;
img.m_instBuf = CTextSupportShader::s_ImgInsts.allocateBlock(CGraphics::g_BooFactory, 1);
auto iBufInfo = img.m_instBuf.getBufferInfo();
boo::IVertexFormat* vFmt = CTextSupportShader::s_ImageVtxFmt;
if (ctx.bindingNeedsVertexFormat())
{
boo::IGraphicsBufferD* buf = iBufInfo.first;
boo::VertexElementDescriptor elems[] =
{
{img.m_instBuf, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 0},
{img.m_instBuf, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 1},
{img.m_instBuf, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 2},
{img.m_instBuf, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 3},
{img.m_instBuf, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 0},
{img.m_instBuf, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 1},
{img.m_instBuf, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 2},
{img.m_instBuf, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 3},
{img.m_instBuf, nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced, 0},
{buf, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 0},
{buf, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 1},
{buf, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 2},
{buf, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 3},
{buf, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 0},
{buf, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 1},
{buf, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 2},
{buf, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 3},
{buf, nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced, 0},
};
vFmt = ctx.newVertexFormat(9, elems);
vFmt = ctx.newVertexFormat(9, elems, 0, iBufInfo.second);
}
boo::IGraphicsBuffer* uniforms[] = {m_uniBuf};
boo::IGraphicsBuffer* uniforms[] = {uBufInfo.first};
boo::PipelineStage unistages[] = {boo::PipelineStage::Vertex};
size_t unioffs[] = {uBufInfo.second};
size_t unisizes[] = {sizeof(CTextSupportShader::Uniform)};
img.m_dataBinding.reserve(img.m_imageDef.x4_texs.size());
for (TToken<CTexture>& tex : img.m_imageDef.x4_texs)
{
boo::ITexture* texs[] = {tex->GetBooTexture()};
img.m_dataBinding.push_back(ctx.newShaderDataBinding(g_TextImageShaderPipeline, vFmt,
nullptr, img.m_instBuf, nullptr,
1, uniforms, nullptr, 1, texs));
img.m_dataBinding.push_back(ctx.newShaderDataBinding(CTextSupportShader::SelectImagePipeline(m_drawFlags),
vFmt, nullptr, iBufInfo.first, nullptr,
1, uniforms, unistages, unioffs,
unisizes, 1, texs, 0, iBufInfo.second));
}
}
return true;
@ -169,6 +155,7 @@ void CTextRenderBuffer::SetMode(EMode mode)
fc.m_charData.reserve(fc.m_charCount);
}
m_activeFontCh = -1;
x0_mode = mode;
}
void CTextRenderBuffer::SetPrimitiveOpacity(int idx, float opacity)
@ -180,26 +167,34 @@ void CTextRenderBuffer::Render(const zeus::CColor& col, float time) const
{
const_cast<CTextRenderBuffer*>(this)->CommitResources();
BooUniform uniforms = {CGraphics::GetPerspectiveProjectionMatrix(true) *
CGraphics::g_GXModelView.toMatrix4f(), col};
m_uniBuf->load(&uniforms, sizeof(uniforms));
zeus::CMatrix4f mv = CGraphics::g_GXModelView.toMatrix4f();
zeus::CMatrix4f proj = CGraphics::GetPerspectiveProjectionMatrix(true);
zeus::CMatrix4f mat = proj * mv;
const_cast<CTextRenderBuffer*>(this)->m_uniBuf.access() =
CTextSupportShader::Uniform{mat, col};
for (const BooFontCharacters& chs : m_fontCharacters)
{
if (chs.m_dirty)
if (chs.m_charData.size())
{
chs.m_instBuf->load(chs.m_charData.data(), sizeof(BooCharacterInstance) * chs.m_charData.size());
((BooFontCharacters&)chs).m_dirty = false;
if (chs.m_dirty)
{
memmove(const_cast<BooFontCharacters&>(chs).m_instBuf.access(),
chs.m_charData.data(), sizeof(CTextSupportShader::CharacterInstance) *
chs.m_charData.size());
const_cast<BooFontCharacters&>(chs).m_dirty = false;
}
CGraphics::SetShaderDataBinding(chs.m_dataBinding);
CGraphics::DrawInstances(0, 4, chs.m_charData.size());
}
CGraphics::SetShaderDataBinding(chs.m_dataBinding);
CGraphics::DrawInstances(0, 4, chs.m_charData.size());
}
for (const BooImage& img : m_images)
{
if (img.m_dirty)
{
img.m_instBuf->load(&img.m_imageData, sizeof(BooImageInstance));
*const_cast<BooImage&>(img).m_instBuf.access() = img.m_imageData;
const_cast<BooImage&>(img).m_dirty = false;
}
int idx = int(img.m_imageDef.x0_fps * time) % img.m_dataBinding.size();
@ -216,7 +211,7 @@ void CTextRenderBuffer::AddImage(const zeus::CVector2i& offset, const CFontImage
m_images.push_back({image, offset});
}
void CTextRenderBuffer::AddCharacter(const zeus::CVector2i& offset, wchar_t ch,
void CTextRenderBuffer::AddCharacter(const zeus::CVector2i& offset, char16_t ch,
const zeus::CColor& color)
{
if (m_activeFontCh == -1)
@ -228,7 +223,7 @@ void CTextRenderBuffer::AddCharacter(const zeus::CVector2i& offset, wchar_t ch,
{
const CGlyph* glyph = chs.m_font.GetObj()->GetGlyph(ch);
chs.m_charData.emplace_back();
BooCharacterInstance& inst = chs.m_charData.back();
CTextSupportShader::CharacterInstance& inst = chs.m_charData.back();
inst.SetMetrics(*glyph, offset);
inst.m_fontColor = m_main * color;
inst.m_outlineColor = m_outline * color;
@ -278,7 +273,7 @@ std::pair<zeus::CVector2i, zeus::CVector2i> CTextRenderBuffer::AccumulateTextBou
for (const BooFontCharacters& chars : m_fontCharacters)
{
for (const BooCharacterInstance& charInst : chars.m_charData)
for (const CTextSupportShader::CharacterInstance& charInst : chars.m_charData)
{
ret.first.x = std::min(ret.first.x, int(charInst.m_pos[0].x));
ret.first.y = std::min(ret.first.y, int(charInst.m_pos[0].z));

View File

@ -8,7 +8,8 @@
#include "CToken.hpp"
#include "CFontImageDef.hpp"
#include "RetroTypes.hpp"
#include "CGuiWidget.hpp"
#include "Graphics/Shaders/CTextSupportShader.hpp"
#include "boo/graphicsdev/IGraphicsDataFactory.hpp"
namespace urde
@ -23,6 +24,7 @@ using CTextColor = zeus::CColor;
class CTextRenderBuffer
{
friend class CGuiTextSupport;
friend class CTextSupportShader;
public:
enum class Command
{
@ -64,50 +66,27 @@ private:
#else
/* Boo-specific text-rendering functionality */
struct BooUniform
{
zeus::CMatrix4f m_mvp;
zeus::CColor m_uniformColor;
};
boo::IGraphicsBufferD* m_uniBuf;
struct BooCharacterInstance
{
zeus::CVector3f m_pos[4];
zeus::CVector2f m_uv[4];
zeus::CColor m_fontColor;
zeus::CColor m_outlineColor;
void SetMetrics(const CGlyph& glyph, const zeus::CVector2i& offset);
};
struct BooImageInstance
{
zeus::CVector3f m_pos[4];
zeus::CVector2f m_uv[4];
zeus::CColor m_color;
};
hecl::UniformBufferPool<CTextSupportShader::Uniform>::Token m_uniBuf;
struct BooFontCharacters
{
TToken<CRasterFont> m_font;
boo::IGraphicsBufferD* m_instBuf = nullptr;
TLockedToken<CRasterFont> m_font;
hecl::VertexBufferPool<CTextSupportShader::CharacterInstance>::Token m_instBuf;
boo::IShaderDataBinding* m_dataBinding = nullptr;
std::vector<BooCharacterInstance> m_charData;
std::vector<CTextSupportShader::CharacterInstance> m_charData;
u32 m_charCount = 0;
bool m_dirty = true;
BooFontCharacters(const CToken& token)
: m_font(token)
{
}
: m_font(token) {}
};
std::vector<BooFontCharacters> m_fontCharacters;
struct BooImage
{
CFontImageDef m_imageDef;
boo::IGraphicsBufferD* m_instBuf = nullptr;
hecl::VertexBufferPool<CTextSupportShader::ImageInstance>::Token m_instBuf;
std::vector<boo::IShaderDataBinding*> m_dataBinding;
BooImageInstance m_imageData;
CTextSupportShader::ImageInstance m_imageData;
bool m_dirty = true;
BooImage(const CFontImageDef& imgDef, const zeus::CVector2i& offset);
};
@ -129,12 +108,14 @@ private:
zeus::CColor m_main;
zeus::CColor m_outline;
CGuiWidget::EGuiModelDrawFlags m_drawFlags;
bool m_committed = false;
void CommitResources();
#endif
public:
CTextRenderBuffer(EMode mode);
CTextRenderBuffer(EMode mode, CGuiWidget::EGuiModelDrawFlags df);
#if 0
void SetPrimitive(const Primitive&, int);
Primitive GetPrimitive(int) const;
@ -150,7 +131,7 @@ public:
void SetMode(EMode mode);
void Render(const zeus::CColor& col, float) const;
void AddImage(const zeus::CVector2i& offset, const CFontImageDef& image);
void AddCharacter(const zeus::CVector2i& offset, wchar_t ch, const zeus::CColor& color);
void AddCharacter(const zeus::CVector2i& offset, char16_t ch, const zeus::CColor& color);
void AddPaletteChange(const zeus::CColor& main, const zeus::CColor& outline);
void AddFontChange(const TToken<CRasterFont>& font);

View File

@ -175,6 +175,7 @@ void CFrontEndUI::SNewFileSelectFrame::Update(float dt)
}
if (x10c_saveReady)
SetupFrameContents();
x1c_loadedFrame->Update(dt);
}
@ -1246,7 +1247,7 @@ CFrontEndUI::SNesEmulatorFrame::SNesEmulatorFrame()
ETextDirection::Horizontal);
xc_textSupport = std::make_unique<CGuiTextSupport>(deface->id, props, zeus::CColor::skWhite,
zeus::CColor::skBlack, zeus::CColor::skWhite,
0, 0, g_SimplePool);
0, 0, g_SimplePool, CGuiWidget::EGuiModelDrawFlags::Alpha);
}
void CFrontEndUI::SNesEmulatorFrame::SetMode(EMode mode)
@ -2002,7 +2003,7 @@ void CFrontEndUI::Draw() const
}
}
if (xdc_saveUI)
if (0 && xdc_saveUI)
{
/* Render memory card feedback strings */
if ((CanShowSaveUI() && !xdc_saveUI->IsHiddenFromFrontEnd()) ||

View File

@ -20,13 +20,15 @@ CSlideShow::CSlideShow()
xc4_textA = std::make_unique<CGuiTextSupport>(font->id, propsA,
g_tweakSlideShow->GetFontColor(),
g_tweakSlideShow->GetOutlineColor(),
zeus::CColor::skWhite, 640, 480, g_SimplePool);
zeus::CColor::skWhite, 640, 480, g_SimplePool,
CGuiWidget::EGuiModelDrawFlags::Alpha);
CGuiTextProperties propsB(false, true, EJustification::Right, EVerticalJustification::Bottom);
xc8_textB = std::make_unique<CGuiTextSupport>(font->id, propsB,
g_tweakSlideShow->GetFontColor(),
g_tweakSlideShow->GetOutlineColor(),
zeus::CColor::skWhite, 640, 480, g_SimplePool);
zeus::CColor::skWhite, 640, 480, g_SimplePool,
CGuiWidget::EGuiModelDrawFlags::Alpha);
}
xf8_stickTextures.reserve(18);

View File

@ -7,6 +7,7 @@
#include "Graphics/Shaders/CTexturedQuadFilter.hpp"
#include "Graphics/Shaders/CCameraBlurFilter.hpp"
#include "Graphics/Shaders/CXRayBlurFilter.hpp"
#include "Graphics/Shaders/CTextSupportShader.hpp"
#include "Character/CCharLayoutInfo.hpp"
#include "Audio/CStreamAudioManager.hpp"
#include "CGBASupport.hpp"
@ -23,6 +24,7 @@ URDE_DECL_SPECIALIZE_SHADER(CXRayBlurFilter)
URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CColoredQuadFilter)
URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CTexturedQuadFilter)
URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CTexturedQuadFilterAlpha)
URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CTextSupportShader)
namespace MP1
{
@ -46,8 +48,8 @@ CGameArchitectureSupport::CGameArchitectureSupport(CMain& parent, boo::IAudioVoi
CStreamAudioManager::Initialize();
m->ResetGameState();
std::shared_ptr<CIOWin> splash = std::make_shared<CSplashScreen>(CSplashScreen::ESplashScreen::Nintendo);
x58_ioWinManager.AddIOWin(splash, 1000, 10000);
//std::shared_ptr<CIOWin> splash = std::make_shared<CSplashScreen>(CSplashScreen::ESplashScreen::Nintendo);
//x58_ioWinManager.AddIOWin(splash, 1000, 10000);
std::shared_ptr<CIOWin> mf = std::make_shared<CMainFlow>();
x58_ioWinManager.AddIOWin(mf, 0, 0);
@ -201,6 +203,7 @@ CMain::BooSetter::BooSetter(boo::IGraphicsDataFactory* factory,
TMultiBlendShader<CColoredQuadFilter>::Initialize();
TMultiBlendShader<CTexturedQuadFilter>::Initialize();
TMultiBlendShader<CTexturedQuadFilterAlpha>::Initialize();
TMultiBlendShader<CTextSupportShader>::Initialize();
}
void CMain::RegisterResourceTweaks()
@ -303,6 +306,7 @@ void CMain::Shutdown()
TMultiBlendShader<CColoredQuadFilter>::Shutdown();
TMultiBlendShader<CTexturedQuadFilter>::Shutdown();
TMultiBlendShader<CTexturedQuadFilterAlpha>::Shutdown();
TMultiBlendShader<CTextSupportShader>::Shutdown();
}
#if MP1_USE_BOO

View File

@ -385,7 +385,7 @@ void CWorldTransManager::EnableTransition(ResId fontId, ResId stringId, bool b1,
EVerticalJustification::Center, ETextDirection::Horizontal);
x8_textData.reset(new CGuiTextSupport(fontId, props, zeus::CColor::skWhite,
zeus::CColor::skBlack, zeus::CColor::skWhite,
640, 448, g_SimplePool));
640, 448, g_SimplePool, CGuiWidget::EGuiModelDrawFlags::Alpha));
x8_textData->SetTypeWriteEffectOptions(true, chFadeTime, chFadeRate);
xc_strTable = g_SimplePool->GetObj(SObjectTag{FOURCC('STRG'), stringId});

2
hecl

@ -1 +1 @@
Subproject commit cef5e394b9f29850e2ec299bf39f33bc0f9f5a10
Subproject commit d4fd78673feebcc5b29eba53178e545cee695891

@ -1 +1 @@
Subproject commit 661b391cd0277bb6de3aeb74d53c990e6ec07099
Subproject commit ba23dd8d9449076c1ebf7c010c1b45c599456792