Metal shader fixes

This commit is contained in:
Jack Andersen 2019-02-03 14:01:44 -10:00
parent 0bb51f067c
commit a353c7ddcf
5 changed files with 19 additions and 15 deletions

View File

@ -118,6 +118,7 @@ else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-multichar -fno-exceptions -fno-rtti -Werror")
if(APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=deprecated-declarations")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -flto=thin")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -flto=thin")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -flto=thin")

View File

@ -57,13 +57,13 @@ struct Application : boo::IApplicationCallback {
std::atomic_bool m_running = {true};
Application() : m_fileMgr(_SYS_STR("urde")), m_cvarManager(m_fileMgr), m_cvarCommons(m_cvarManager) {}
Application() : m_fileMgr(_SYS_STR("urde")), m_cvarManager(m_fileMgr), m_cvarCommons(m_cvarManager),
m_viewManager(std::make_unique<ViewManager>(m_fileMgr, m_cvarManager)) {}
virtual ~Application() = default;
int appMain(boo::IApplication* app) {
initialize(app);
m_viewManager = std::make_unique<ViewManager>(m_fileMgr, m_cvarManager);
m_viewManager->init(app);
while (m_running.load()) {
if (!m_viewManager->proc())
@ -187,6 +187,9 @@ int main(int argc, const boo::SystemChar** argv)
ExeDir.insert(ExeDir.end(), Argv0.begin(), Argv0.begin() + lastIdx);
}
/* Handle -j argument */
hecl::SetCpuCountOverride(argc, argv);
urde::Application appCb;
int ret = boo::ApplicationRun(boo::IApplication::EPlatformType::Auto, appCb, _SYS_STR("urde"), _SYS_STR("URDE"), argc,
argv, appCb.getGraphicsApi(), appCb.getSamples(), appCb.getAnisotropy(),

View File

@ -75,6 +75,7 @@ static const char* BlockNames[] = {"LightingUniform"};
static const char* ThermalBlockNames[] = {"ThermalUniform"};
static const char* SolidBlockNames[] = {"SolidUniform"};
static const char* MBShadowBlockNames[] = {"MBShadowUniform"};
static const char* DisintegrateBlockNames[] = {"DisintegrateUniform"};
static hecl::Backend::ExtensionSlot g_ExtensionSlots[] = {
/* Default solid shading */
@ -138,7 +139,7 @@ static hecl::Backend::ExtensionSlot g_ExtensionSlots[] = {
{1, BlockNames, 0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::InvSrcAlpha,
hecl::Backend::ZTest::GEqual, hecl::Backend::CullMode::Backface, true, false, true},
/* Disintegration */
{1, BlockNames, 2, DisintegrateTextures, hecl::Backend::BlendFactor::SrcAlpha,
{1, DisintegrateBlockNames, 2, DisintegrateTextures, hecl::Backend::BlendFactor::SrcAlpha,
hecl::Backend::BlendFactor::InvSrcAlpha, hecl::Backend::ZTest::LEqual, hecl::Backend::CullMode::Original, false,
false, true, false, false, true},
/* Forced additive shading without culling or Z-write and greater depth test */
@ -185,11 +186,15 @@ CModelShaders::ShaderPipelines CModelShaders::BuildExtendedShader(const hecl::Ba
auto search = g_ShaderPipelines.find(tag.val64());
if (search != g_ShaderPipelines.cend())
return search->second;
ShaderPipelines& newPipelines = g_ShaderPipelines[tag.val64()];
newPipelines = std::make_shared<ShaderPipelinesData>();
size_t idx = 0;
for (const auto& ext : g_ExtensionSlots)
(*newPipelines)[idx++] = hecl::conv->convert(hecl::HECLIR(ir, tag, ext));
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
size_t idx = 0;
for (const auto& ext : g_ExtensionSlots)
(*newPipelines)[idx++] = hecl::conv->convert(ctx, hecl::HECLIR(ir, tag, ext));
return true;
} BooTrace);
return newPipelines;
}
} // namespace urde

View File

@ -212,10 +212,10 @@ static std::string_view DisintegratePostMetal = FOG_STRUCT_METAL
"static float4 EXTDisintegratePostFunc(thread VertToFrag& vtf, constant DisintegrateUniform& lu, sampler samp,\n"
" sampler clampSamp, texture2d<float> extTex7, float4 colorIn)\n"
"{\n"
" float4 texel0 = extTex7.sample(samp, vtf.extTcgs[0]);\n"
" float4 texel1 = extTex7.sample(samp, vtf.extTcgs[1]);\n"
" float4 texel0 = extTex7.sample(samp, vtf.extTcgs0);\n"
" float4 texel1 = extTex7.sample(samp, vtf.extTcgs1);\n"
" colorIn = mix(float4(0.0), texel1, texel0);\n"
" colorIn.rgb += addColor.rgb;\n" FOG_ALGORITHM_METAL
" colorIn.rgb += lu.addColor.rgb;\n" FOG_ALGORITHM_METAL
"}\n"
"\n"sv;
@ -267,9 +267,4 @@ const hecl::Backend::Function ExtensionPostFuncsMetal[] = {
{MainPostMetal, "MainPostFunc"},
};
static const char* BlockNames[] = {"LightingUniform"};
static const char* ThermalBlockNames[] = {"ThermalUniform"};
static const char* SolidBlockNames[] = {"SolidUniform"};
static const char* MBShadowBlockNames[] = {"MBShadowUniform"};
} // namespace urde

2
hecl

@ -1 +1 @@
Subproject commit d51204a7b74b38a17f219ce53ccc7fcc1f503db4
Subproject commit 04a725a2621be5217354bad5dd01e5cb786f941c