mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-12 16:06:09 +00:00
Update boo and Metal backend
This commit is contained in:
2
hecl/extern/boo
vendored
2
hecl/extern/boo
vendored
Submodule hecl/extern/boo updated: 4c8e36f3e3...843396095f
@@ -1,7 +1,19 @@
|
|||||||
#ifndef HECLBACKEND_METAL_HPP
|
#ifndef HECLBACKEND_METAL_HPP
|
||||||
#define HECLBACKEND_METAL_HPP
|
#define HECLBACKEND_METAL_HPP
|
||||||
|
|
||||||
|
#if __APPLE__
|
||||||
|
#include <Availability.h>
|
||||||
|
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 101100
|
||||||
|
#define BOO_HAS_METAL 1
|
||||||
|
#else
|
||||||
|
#define BOO_HAS_METAL 0
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#if BOO_HAS_METAL
|
#if BOO_HAS_METAL
|
||||||
|
|
||||||
|
#include "ProgrammableCommon.hpp"
|
||||||
|
|
||||||
namespace hecl
|
namespace hecl
|
||||||
{
|
{
|
||||||
namespace Backend
|
namespace Backend
|
||||||
|
|||||||
@@ -172,7 +172,7 @@ std::string Metal::makeFrag(const ShaderFunction& lighting) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string retval = "#include <metal_stdlib>\nusing namespace metal;\n"
|
std::string retval = "#include <metal_stdlib>\nusing namespace metal;\n"
|
||||||
"constexpr sampler samp(address::repeat);\n" +
|
"constexpr sampler samp(address::repeat, filter::linear, mip_filter::linear);\n" +
|
||||||
GenerateVertToFragStruct() + "\n" +
|
GenerateVertToFragStruct() + "\n" +
|
||||||
lightingSrc + "\n" +
|
lightingSrc + "\n" +
|
||||||
"fragment float4 fmain(VertToFrag vtf [[ stage_in ]]" + texMapDecl + ")\n{\n";
|
"fragment float4 fmain(VertToFrag vtf [[ stage_in ]]" + texMapDecl + ")\n{\n";
|
||||||
@@ -222,7 +222,7 @@ std::string Metal::makeFrag(const ShaderFunction& lighting,
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string retval = "#include <metal_stdlib>\nusing namespace metal;\n"
|
std::string retval = "#include <metal_stdlib>\nusing namespace metal;\n"
|
||||||
"constexpr sampler samp(address::repeat);\n" +
|
"constexpr sampler samp(address::repeat, filter::linear, mip_filter::linear);\n" +
|
||||||
GenerateVertToFragStruct() + "\n" +
|
GenerateVertToFragStruct() + "\n" +
|
||||||
lightingSrc + "\n" +
|
lightingSrc + "\n" +
|
||||||
"fragment float4 fmain(VertToFrag vtf [[ stage_in ]],\n" + texMapDecl + ")\n{\n";
|
"fragment float4 fmain(VertToFrag vtf [[ stage_in ]],\n" + texMapDecl + ")\n{\n";
|
||||||
@@ -255,14 +255,11 @@ namespace Runtime
|
|||||||
struct MetalBackendFactory : IShaderBackendFactory
|
struct MetalBackendFactory : IShaderBackendFactory
|
||||||
{
|
{
|
||||||
Backend::Metal m_backend;
|
Backend::Metal m_backend;
|
||||||
boo::MetalDataFactory* m_gfxFactory;
|
|
||||||
|
|
||||||
MetalBackendFactory(boo::IGraphicsDataFactory* gfxFactory)
|
|
||||||
: m_gfxFactory(dynamic_cast<boo::MetalDataFactory*>(gfxFactory)) {}
|
|
||||||
|
|
||||||
ShaderCachedData buildShaderFromIR(const ShaderTag& tag,
|
ShaderCachedData buildShaderFromIR(const ShaderTag& tag,
|
||||||
const hecl::Frontend::IR& ir,
|
const hecl::Frontend::IR& ir,
|
||||||
hecl::Frontend::Diagnostics& diag,
|
hecl::Frontend::Diagnostics& diag,
|
||||||
|
boo::IGraphicsDataFactory::Context& ctx,
|
||||||
boo::IShaderPipeline*& objOut)
|
boo::IShaderPipeline*& objOut)
|
||||||
{
|
{
|
||||||
if (!m_rtHint)
|
if (!m_rtHint)
|
||||||
@@ -280,12 +277,14 @@ struct MetalBackendFactory : IShaderBackendFactory
|
|||||||
std::string fragSource = m_backend.makeFrag();
|
std::string fragSource = m_backend.makeFrag();
|
||||||
cachedSz += fragSource.size() + 1;
|
cachedSz += fragSource.size() + 1;
|
||||||
objOut =
|
objOut =
|
||||||
m_gfxFactory->newShaderPipeline(vertSource.c_str(), fragSource.c_str(),
|
static_cast<boo::MetalDataFactory::Context&>(ctx).
|
||||||
tag.newVertexFormat(m_gfxFactory), m_rtHint,
|
newShaderPipeline(vertSource.c_str(), fragSource.c_str(),
|
||||||
m_backend.m_blendSrc, m_backend.m_blendDst,
|
tag.newVertexFormat(ctx), m_rtHint,
|
||||||
tag.getDepthTest(), tag.getDepthWrite(),
|
m_backend.m_blendSrc, m_backend.m_blendDst,
|
||||||
tag.getBackfaceCulling());
|
tag.getPrimType(),
|
||||||
if (!*objOut)
|
tag.getDepthTest(), tag.getDepthWrite(),
|
||||||
|
tag.getBackfaceCulling());
|
||||||
|
if (!objOut)
|
||||||
Log.report(logvisor::Fatal, "unable to build shader");
|
Log.report(logvisor::Fatal, "unable to build shader");
|
||||||
|
|
||||||
ShaderCachedData dataOut(tag, cachedSz);
|
ShaderCachedData dataOut(tag, cachedSz);
|
||||||
@@ -298,7 +297,8 @@ struct MetalBackendFactory : IShaderBackendFactory
|
|||||||
return dataOut;
|
return dataOut;
|
||||||
}
|
}
|
||||||
|
|
||||||
boo::IShaderPipeline* buildShaderFromCache(const ShaderCachedData& data)
|
boo::IShaderPipeline* buildShaderFromCache(const ShaderCachedData& data,
|
||||||
|
boo::IGraphicsDataFactory::Context& ctx)
|
||||||
{
|
{
|
||||||
if (!m_rtHint)
|
if (!m_rtHint)
|
||||||
Log.report(logvisor::Fatal,
|
Log.report(logvisor::Fatal,
|
||||||
@@ -311,11 +311,12 @@ struct MetalBackendFactory : IShaderBackendFactory
|
|||||||
std::string vertSource = r.readString();
|
std::string vertSource = r.readString();
|
||||||
std::string fragSource = r.readString();
|
std::string fragSource = r.readString();
|
||||||
boo::IShaderPipeline* ret =
|
boo::IShaderPipeline* ret =
|
||||||
m_gfxFactory->newShaderPipeline(vertSource.c_str(), fragSource.c_str(),
|
static_cast<boo::MetalDataFactory::Context&>(ctx).
|
||||||
tag.newVertexFormat(m_gfxFactory), m_rtHint,
|
newShaderPipeline(vertSource.c_str(), fragSource.c_str(),
|
||||||
blendSrc, blendDst,
|
tag.newVertexFormat(ctx), m_rtHint,
|
||||||
tag.getDepthTest(), tag.getDepthWrite(),
|
blendSrc, blendDst, tag.getPrimType(),
|
||||||
tag.getBackfaceCulling());
|
tag.getDepthTest(), tag.getDepthWrite(),
|
||||||
|
tag.getBackfaceCulling());
|
||||||
if (!ret)
|
if (!ret)
|
||||||
Log.report(logvisor::Fatal, "unable to build shader");
|
Log.report(logvisor::Fatal, "unable to build shader");
|
||||||
return ret;
|
return ret;
|
||||||
@@ -325,6 +326,7 @@ struct MetalBackendFactory : IShaderBackendFactory
|
|||||||
const hecl::Frontend::IR& ir,
|
const hecl::Frontend::IR& ir,
|
||||||
hecl::Frontend::Diagnostics& diag,
|
hecl::Frontend::Diagnostics& diag,
|
||||||
const std::vector<ShaderCacheExtensions::ExtensionSlot>& extensionSlots,
|
const std::vector<ShaderCacheExtensions::ExtensionSlot>& extensionSlots,
|
||||||
|
boo::IGraphicsDataFactory::Context& ctx,
|
||||||
FReturnExtensionShader returnFunc)
|
FReturnExtensionShader returnFunc)
|
||||||
{
|
{
|
||||||
if (!m_rtHint)
|
if (!m_rtHint)
|
||||||
@@ -346,11 +348,13 @@ struct MetalBackendFactory : IShaderBackendFactory
|
|||||||
fragSources.push_back(m_backend.makeFrag(slot.lighting, slot.post));
|
fragSources.push_back(m_backend.makeFrag(slot.lighting, slot.post));
|
||||||
cachedSz += fragSources.back().size() + 1;
|
cachedSz += fragSources.back().size() + 1;
|
||||||
boo::IShaderPipeline* ret =
|
boo::IShaderPipeline* ret =
|
||||||
m_gfxFactory->newShaderPipeline(vertSource.c_str(), fragSources.back().c_str(),
|
static_cast<boo::MetalDataFactory::Context&>(ctx).
|
||||||
tag.newVertexFormat(m_gfxFactory), m_rtHint,
|
newShaderPipeline(vertSource.c_str(), fragSources.back().c_str(),
|
||||||
m_backend.m_blendSrc, m_backend.m_blendDst,
|
tag.newVertexFormat(ctx), m_rtHint,
|
||||||
tag.getDepthTest(), tag.getDepthWrite(),
|
m_backend.m_blendSrc, m_backend.m_blendDst,
|
||||||
tag.getBackfaceCulling());
|
tag.getPrimType(),
|
||||||
|
tag.getDepthTest(), tag.getDepthWrite(),
|
||||||
|
tag.getBackfaceCulling());
|
||||||
if (!ret)
|
if (!ret)
|
||||||
Log.report(logvisor::Fatal, "unable to build shader");
|
Log.report(logvisor::Fatal, "unable to build shader");
|
||||||
returnFunc(ret);
|
returnFunc(ret);
|
||||||
@@ -369,6 +373,7 @@ struct MetalBackendFactory : IShaderBackendFactory
|
|||||||
|
|
||||||
void buildExtendedShaderFromCache(const ShaderCachedData& data,
|
void buildExtendedShaderFromCache(const ShaderCachedData& data,
|
||||||
const std::vector<ShaderCacheExtensions::ExtensionSlot>& extensionSlots,
|
const std::vector<ShaderCacheExtensions::ExtensionSlot>& extensionSlots,
|
||||||
|
boo::IGraphicsDataFactory::Context& ctx,
|
||||||
FReturnExtensionShader returnFunc)
|
FReturnExtensionShader returnFunc)
|
||||||
{
|
{
|
||||||
if (!m_rtHint)
|
if (!m_rtHint)
|
||||||
@@ -384,11 +389,12 @@ struct MetalBackendFactory : IShaderBackendFactory
|
|||||||
{
|
{
|
||||||
std::string fragSource = r.readString();
|
std::string fragSource = r.readString();
|
||||||
boo::IShaderPipeline* ret =
|
boo::IShaderPipeline* ret =
|
||||||
m_gfxFactory->newShaderPipeline(vertSource.c_str(), fragSource.c_str(),
|
static_cast<boo::MetalDataFactory::Context&>(ctx).
|
||||||
tag.newVertexFormat(m_gfxFactory), m_rtHint,
|
newShaderPipeline(vertSource.c_str(), fragSource.c_str(),
|
||||||
blendSrc, blendDst,
|
tag.newVertexFormat(ctx), m_rtHint,
|
||||||
tag.getDepthTest(), tag.getDepthWrite(),
|
blendSrc, blendDst, tag.getPrimType(),
|
||||||
tag.getBackfaceCulling());
|
tag.getDepthTest(), tag.getDepthWrite(),
|
||||||
|
tag.getBackfaceCulling());
|
||||||
if (!ret)
|
if (!ret)
|
||||||
Log.report(logvisor::Fatal, "unable to build shader");
|
Log.report(logvisor::Fatal, "unable to build shader");
|
||||||
returnFunc(ret);
|
returnFunc(ret);
|
||||||
@@ -396,9 +402,9 @@ struct MetalBackendFactory : IShaderBackendFactory
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
IShaderBackendFactory* _NewMetalBackendFactory(boo::IGraphicsDataFactory* gfxFactory)
|
IShaderBackendFactory* _NewMetalBackendFactory()
|
||||||
{
|
{
|
||||||
return new struct MetalBackendFactory(gfxFactory);
|
return new struct MetalBackendFactory();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user