mirror of https://github.com/AxioDL/metaforce.git
Update boo and Metal backend
This commit is contained in:
parent
3b757c9854
commit
54ca41f2ed
|
@ -1 +1 @@
|
|||
Subproject commit 4c8e36f3e33582bca396b3b89e29178ebc2f1728
|
||||
Subproject commit 843396095f8cbc160541edfcbf1a22c0030d397c
|
|
@ -1,7 +1,19 @@
|
|||
#ifndef 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
|
||||
|
||||
#include "ProgrammableCommon.hpp"
|
||||
|
||||
namespace hecl
|
||||
{
|
||||
namespace Backend
|
||||
|
|
|
@ -172,7 +172,7 @@ std::string Metal::makeFrag(const ShaderFunction& lighting) const
|
|||
}
|
||||
|
||||
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" +
|
||||
lightingSrc + "\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"
|
||||
"constexpr sampler samp(address::repeat);\n" +
|
||||
"constexpr sampler samp(address::repeat, filter::linear, mip_filter::linear);\n" +
|
||||
GenerateVertToFragStruct() + "\n" +
|
||||
lightingSrc + "\n" +
|
||||
"fragment float4 fmain(VertToFrag vtf [[ stage_in ]],\n" + texMapDecl + ")\n{\n";
|
||||
|
@ -255,14 +255,11 @@ namespace Runtime
|
|||
struct MetalBackendFactory : IShaderBackendFactory
|
||||
{
|
||||
Backend::Metal m_backend;
|
||||
boo::MetalDataFactory* m_gfxFactory;
|
||||
|
||||
MetalBackendFactory(boo::IGraphicsDataFactory* gfxFactory)
|
||||
: m_gfxFactory(dynamic_cast<boo::MetalDataFactory*>(gfxFactory)) {}
|
||||
|
||||
ShaderCachedData buildShaderFromIR(const ShaderTag& tag,
|
||||
const hecl::Frontend::IR& ir,
|
||||
hecl::Frontend::Diagnostics& diag,
|
||||
boo::IGraphicsDataFactory::Context& ctx,
|
||||
boo::IShaderPipeline*& objOut)
|
||||
{
|
||||
if (!m_rtHint)
|
||||
|
@ -280,12 +277,14 @@ struct MetalBackendFactory : IShaderBackendFactory
|
|||
std::string fragSource = m_backend.makeFrag();
|
||||
cachedSz += fragSource.size() + 1;
|
||||
objOut =
|
||||
m_gfxFactory->newShaderPipeline(vertSource.c_str(), fragSource.c_str(),
|
||||
tag.newVertexFormat(m_gfxFactory), m_rtHint,
|
||||
static_cast<boo::MetalDataFactory::Context&>(ctx).
|
||||
newShaderPipeline(vertSource.c_str(), fragSource.c_str(),
|
||||
tag.newVertexFormat(ctx), m_rtHint,
|
||||
m_backend.m_blendSrc, m_backend.m_blendDst,
|
||||
tag.getPrimType(),
|
||||
tag.getDepthTest(), tag.getDepthWrite(),
|
||||
tag.getBackfaceCulling());
|
||||
if (!*objOut)
|
||||
if (!objOut)
|
||||
Log.report(logvisor::Fatal, "unable to build shader");
|
||||
|
||||
ShaderCachedData dataOut(tag, cachedSz);
|
||||
|
@ -298,7 +297,8 @@ struct MetalBackendFactory : IShaderBackendFactory
|
|||
return dataOut;
|
||||
}
|
||||
|
||||
boo::IShaderPipeline* buildShaderFromCache(const ShaderCachedData& data)
|
||||
boo::IShaderPipeline* buildShaderFromCache(const ShaderCachedData& data,
|
||||
boo::IGraphicsDataFactory::Context& ctx)
|
||||
{
|
||||
if (!m_rtHint)
|
||||
Log.report(logvisor::Fatal,
|
||||
|
@ -311,9 +311,10 @@ struct MetalBackendFactory : IShaderBackendFactory
|
|||
std::string vertSource = r.readString();
|
||||
std::string fragSource = r.readString();
|
||||
boo::IShaderPipeline* ret =
|
||||
m_gfxFactory->newShaderPipeline(vertSource.c_str(), fragSource.c_str(),
|
||||
tag.newVertexFormat(m_gfxFactory), m_rtHint,
|
||||
blendSrc, blendDst,
|
||||
static_cast<boo::MetalDataFactory::Context&>(ctx).
|
||||
newShaderPipeline(vertSource.c_str(), fragSource.c_str(),
|
||||
tag.newVertexFormat(ctx), m_rtHint,
|
||||
blendSrc, blendDst, tag.getPrimType(),
|
||||
tag.getDepthTest(), tag.getDepthWrite(),
|
||||
tag.getBackfaceCulling());
|
||||
if (!ret)
|
||||
|
@ -325,6 +326,7 @@ struct MetalBackendFactory : IShaderBackendFactory
|
|||
const hecl::Frontend::IR& ir,
|
||||
hecl::Frontend::Diagnostics& diag,
|
||||
const std::vector<ShaderCacheExtensions::ExtensionSlot>& extensionSlots,
|
||||
boo::IGraphicsDataFactory::Context& ctx,
|
||||
FReturnExtensionShader returnFunc)
|
||||
{
|
||||
if (!m_rtHint)
|
||||
|
@ -346,9 +348,11 @@ struct MetalBackendFactory : IShaderBackendFactory
|
|||
fragSources.push_back(m_backend.makeFrag(slot.lighting, slot.post));
|
||||
cachedSz += fragSources.back().size() + 1;
|
||||
boo::IShaderPipeline* ret =
|
||||
m_gfxFactory->newShaderPipeline(vertSource.c_str(), fragSources.back().c_str(),
|
||||
tag.newVertexFormat(m_gfxFactory), m_rtHint,
|
||||
static_cast<boo::MetalDataFactory::Context&>(ctx).
|
||||
newShaderPipeline(vertSource.c_str(), fragSources.back().c_str(),
|
||||
tag.newVertexFormat(ctx), m_rtHint,
|
||||
m_backend.m_blendSrc, m_backend.m_blendDst,
|
||||
tag.getPrimType(),
|
||||
tag.getDepthTest(), tag.getDepthWrite(),
|
||||
tag.getBackfaceCulling());
|
||||
if (!ret)
|
||||
|
@ -369,6 +373,7 @@ struct MetalBackendFactory : IShaderBackendFactory
|
|||
|
||||
void buildExtendedShaderFromCache(const ShaderCachedData& data,
|
||||
const std::vector<ShaderCacheExtensions::ExtensionSlot>& extensionSlots,
|
||||
boo::IGraphicsDataFactory::Context& ctx,
|
||||
FReturnExtensionShader returnFunc)
|
||||
{
|
||||
if (!m_rtHint)
|
||||
|
@ -384,9 +389,10 @@ struct MetalBackendFactory : IShaderBackendFactory
|
|||
{
|
||||
std::string fragSource = r.readString();
|
||||
boo::IShaderPipeline* ret =
|
||||
m_gfxFactory->newShaderPipeline(vertSource.c_str(), fragSource.c_str(),
|
||||
tag.newVertexFormat(m_gfxFactory), m_rtHint,
|
||||
blendSrc, blendDst,
|
||||
static_cast<boo::MetalDataFactory::Context&>(ctx).
|
||||
newShaderPipeline(vertSource.c_str(), fragSource.c_str(),
|
||||
tag.newVertexFormat(ctx), m_rtHint,
|
||||
blendSrc, blendDst, tag.getPrimType(),
|
||||
tag.getDepthTest(), tag.getDepthWrite(),
|
||||
tag.getBackfaceCulling());
|
||||
if (!ret)
|
||||
|
@ -396,9 +402,9 @@ struct MetalBackendFactory : IShaderBackendFactory
|
|||
}
|
||||
};
|
||||
|
||||
IShaderBackendFactory* _NewMetalBackendFactory(boo::IGraphicsDataFactory* gfxFactory)
|
||||
IShaderBackendFactory* _NewMetalBackendFactory()
|
||||
{
|
||||
return new struct MetalBackendFactory(gfxFactory);
|
||||
return new struct MetalBackendFactory();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue