Various bug fixes

This commit is contained in:
Jack Andersen 2017-10-21 20:10:59 -10:00
parent ebad51dc2e
commit 48ec4cf6eb
10 changed files with 52 additions and 26 deletions

View File

@ -183,7 +183,7 @@ def recursive_cook(buffer, obj, version, path_hasher, parent_name):
elif obj.retro_widget_type == 'RETRO_ENRG':
path_hash = path_hasher.hashpath32(obj.retro_energybar_texture_path)
buffer += struct.pack('>ffff', path_hash)
buffer += struct.pack('>I', path_hash)
elif obj.retro_widget_type == 'RETRO_METR':
buffer += struct.pack('>bbII',

2
hecl/extern/boo vendored

@ -1 +1 @@
Subproject commit 7eb2b19619117c8f923d8b098e2a2d710cd3363a
Subproject commit 41d225bd64a5e1840a7f4d1ea7bbd33b50cf90aa

View File

@ -4,6 +4,7 @@
#include "hecl.hpp"
#include "Database.hpp"
#include "hecl/Blender/BlenderConnection.hpp"
#include "boo/ThreadLocalPtr.hpp"
#include <list>
#include <thread>
#include <mutex>
@ -80,6 +81,7 @@ private:
void proc();
};
std::vector<Worker> m_workers;
static ThreadLocalPtr<ClientProcess::Worker> ThreadWorker;
public:
ClientProcess(int verbosityLevel=1);
@ -95,6 +97,15 @@ public:
void swapCompletedQueue(std::list<std::shared_ptr<Transaction>>& queue);
void waitUntilComplete();
void shutdown();
bool isBusy() const { return m_pendingQueue.size() || m_inProgress; }
static int GetThreadWorkerIdx()
{
Worker* w = ThreadWorker.get();
if (w)
return w->m_idx;
return -1;
}
};
}

View File

@ -145,6 +145,7 @@ public:
bool noDepthWrite = false;
bool noColorWrite = false;
bool noAlphaWrite = false;
bool noReflection = false;
};
std::vector<ExtensionSlot> m_extensionSlots;
@ -164,7 +165,8 @@ public:
bool frontfaceCull = false,
bool noDepthWrite = false,
bool noColorWrite = false,
bool noAlphaWrite = false)
bool noAlphaWrite = false,
bool noReflection = false)
{
m_extensionSlots.emplace_back();
ExtensionSlot& slot = m_extensionSlots.back();
@ -181,6 +183,7 @@ public:
slot.noDepthWrite = noDepthWrite;
slot.noColorWrite = noColorWrite;
slot.noAlphaWrite = noAlphaWrite;
slot.noReflection = noReflection;
return m_extensionSlots.size() - 1;
}
};
@ -247,7 +250,7 @@ class ShaderCacheManager
};
std::vector<IndexEntry> m_entries;
std::unordered_map<Hash, size_t> m_entryLookup;
std::unordered_map<Hash, std::weak_ptr<ShaderPipelines>> m_pipelineLookup;
std::unordered_map<Hash, std::shared_ptr<ShaderPipelines>> m_pipelineLookup;
uint64_t m_timeHash = 0;
void bootstrapIndex();
@ -265,6 +268,7 @@ public:
boo::IGraphicsDataFactory* gfxFactory)
: ShaderCacheManager(storeMgr, gfxFactory, ShaderCacheExtensions()) {}
void reload();
void clearCachedPipelines() { m_pipelineLookup.clear(); }
/* Some platforms (like Metal) require information about the render target
* for encoding the pipeline state. This must be called before building shaders */

View File

@ -216,8 +216,8 @@ std::string GLSL::makeVert(const char* glslVer, unsigned col, unsigned uv, unsig
}
if (reflectionType != ReflectionType::None)
retval += " vtf.reflectTcgs[0] = normalize((indMtx * vec4(v.posIn, 1.0)).xz) * vec2(0.5, 0.5) + vec2(0.5, 0.5);\n"
" vtf.reflectTcgs[1] = (reflectMtx * vec4(v.posIn, 1.0)).xy;\n"
retval += " vtf.reflectTcgs[0] = normalize((indMtx * vec4(posIn, 1.0)).xz) * vec2(0.5, 0.5) + vec2(0.5, 0.5);\n"
" vtf.reflectTcgs[1] = (reflectMtx * vec4(posIn, 1.0)).xy;\n"
" vtf.reflectAlpha = reflectAlpha;\n";
return retval + "}\n";

View File

@ -396,10 +396,8 @@ std::string Metal::makeFrag(size_t blockCount, const char** blockNames, bool alp
{
if (lighting.m_entry)
{
if (!strncmp(lighting.m_entry, "EXT", 3))
retval += " float4 lighting = " + lightingEntry + "(" + blockCall + ", vtf.mvPos, vtf.mvNorm, vtf, " + (extTexCall.size() ? (extTexCall + ", ") : "") + ");\n";
else
retval += " float4 lighting = " + lightingEntry + "(" + blockCall + ", vtf.mvPos, vtf.mvNorm, vtf);\n";
retval += " float4 lighting = " + lightingEntry + "(" + blockCall + ", vtf.mvPos, vtf.mvNorm, vtf" +
(!strncmp(lighting.m_entry, "EXT", 3) ? (extTexCall.size() ? (", " + extTexCall) : "") : "") + ");\n";
}
else
retval += " float4 lighting = float4(1.0,1.0,1.0,1.0);\n";
@ -413,11 +411,19 @@ std::string Metal::makeFrag(size_t blockCount, const char** blockNames, bool alp
std::string reflectionExpr = GenerateReflectionExpr(reflectionType);
if (m_alphaExpr.size())
retval += " out.color = " + postEntry + "(" + (postEntry.size() ? ("vtf, " + (blockCall.size() ? (blockCall + ", ") : "") + (extTexCall.size() ? (extTexCall + ", ") : "")) : "") +
{
retval += " out.color = " + postEntry + "(" +
(postEntry.size() ? ("vtf, " + (blockCall.size() ? (blockCall + ", ") : "") +
(!strncmp(post.m_entry, "EXT", 3) ? (extTexCall.size() ? (extTexCall + ", ") : "") : "")) : "") +
"float4(" + m_colorExpr + " + " + reflectionExpr + ", " + m_alphaExpr + ")) * mulColor;\n";
}
else
retval += " out.color = " + postEntry + "(" + (postEntry.size() ? ("vtf, " + (blockCall.size() ? (blockCall + ", ") : "") + (extTexCall.size() ? (extTexCall + ", ") : "")) : "") +
{
retval += " out.color = " + postEntry + "(" +
(postEntry.size() ? ("vtf, " + (blockCall.size() ? (blockCall + ", ") : "") +
(!strncmp(post.m_entry, "EXT", 3) ? (extTexCall.size() ? (extTexCall + ", ") : "") : "")) : "") +
"float4(" + m_colorExpr + " + " + reflectionExpr + ", 1.0)) * mulColor;\n";
}
return retval + (alphaTest ? GenerateAlphaTest() : "") +
" //out.depth = 1.0 - float(int((1.0 - vtf.mvpPos.z) * 16777216.0)) / 16777216.0;\n"
@ -526,10 +532,11 @@ struct MetalBackendFactory : IShaderBackendFactory
{
sources.emplace_back(m_backend.makeVert(tag.getColorCount(), tag.getUvCount(), tag.getWeightCount(),
tag.getSkinSlotCount(), tag.getTexMtxCount(), slot.texCount, slot.texs,
tag.getReflectionType()),
slot.noReflection ? Backend::ReflectionType::None : tag.getReflectionType()),
m_backend.makeFrag(slot.blockCount, slot.blockNames,
tag.getDepthWrite() && m_backend.m_blendDst == hecl::Backend::BlendFactor::InvSrcAlpha,
tag.getReflectionType(), slot.lighting, slot.post, slot.texCount, slot.texs));
slot.noReflection ? Backend::ReflectionType::None : tag.getReflectionType(),
slot.lighting, slot.post, slot.texCount, slot.texs));
cachedSz += sources.back().first.size() + 1;
cachedSz += sources.back().second.size() + 1;

View File

@ -191,7 +191,7 @@ std::string ProgrammableCommon::RecursiveTraceAlpha(const IR& ir, Diagnostics& d
{
const IR::Instruction& idxInst = inst.getChildInst(ir, 0);
unsigned idx = unsigned(idxInst.getImmVec().vec[0]);
return EmitColorRegUseAlpha(idx);
return toSwizzle ? EmitColorRegUseRaw(idx) : EmitColorRegUseAlpha(idx);
}
else if (!name.compare("Lighting"))
{

View File

@ -518,7 +518,8 @@ BlenderConnection::BlenderConnection(int verbosityLevel)
InstallAddon(blenderAddonPath.c_str());
++installAttempt;
if (installAttempt >= 2)
BlenderLog.report(logvisor::Fatal, _S("unable to install blender addon using '%s'"), blenderAddonPath.c_str());
BlenderLog.report(logvisor::Fatal, _S("unable to install blender addon using '%s'"),
blenderAddonPath.c_str());
continue;
}
else if (!strcmp(lineBuf, "ADDONINSTALLED"))
@ -600,7 +601,8 @@ bool BlenderConnection::createBlend(const ProjectPath& path, BlendType type)
"BlenderConnection::createBlend() musn't be called with stream active");
return false;
}
_writeStr(("CREATE \"" + path.getAbsolutePathUTF8() + "\" " + BlendTypeStrs[int(type)] + " \"" + m_startupBlend + "\"").c_str());
_writeStr(("CREATE \"" + path.getAbsolutePathUTF8() + "\" " + BlendTypeStrs[int(type)] +
" \"" + m_startupBlend + "\"").c_str());
char lineBuf[256];
_readStr(lineBuf, sizeof(lineBuf));
if (!strcmp(lineBuf, "FINISHED"))

View File

@ -10,10 +10,14 @@
#include <sys/wait.h>
#endif
#define HECL_MULTIPROCESSOR 1
namespace hecl
{
static logvisor::Module Log("hecl::ClientProcess");
ThreadLocalPtr<ClientProcess::Worker> ClientProcess::ThreadWorker;
static int GetCPUCount()
{
#if _WIN32
@ -68,6 +72,8 @@ ClientProcess::Worker::Worker(ClientProcess& proc, int idx)
void ClientProcess::Worker::proc()
{
ClientProcess::ThreadWorker.reset(this);
char thrName[64];
snprintf(thrName, 64, "HECL Client Worker %d", m_idx);
logvisor::RegisterThreadName(thrName);
@ -172,7 +178,7 @@ void ClientProcess::swapCompletedQueue(std::list<std::shared_ptr<Transaction>>&
void ClientProcess::waitUntilComplete()
{
std::unique_lock<std::mutex> lk(m_mutex);
while (m_pendingQueue.size() || m_inProgress)
while (isBusy())
m_waitCv.wait(lk);
}

View File

@ -384,8 +384,7 @@ ShaderCacheManager::buildShader(const ShaderTag& tag, const std::string& source,
{
auto search = m_pipelineLookup.find(tag);
if (search != m_pipelineLookup.cend())
if (auto ret = search->second.lock())
return ret;
return search->second;
std::shared_ptr<ShaderPipelines> ret = std::make_shared<ShaderPipelines>();
ShaderCachedData foundData = lookupData(tag);
@ -432,8 +431,7 @@ ShaderCacheManager::buildShader(const ShaderTag& tag, const hecl::Frontend::IR&
{
auto search = m_pipelineLookup.find(tag);
if (search != m_pipelineLookup.cend())
if (auto ret = search->second.lock())
return ret;
return search->second;
std::shared_ptr<ShaderPipelines> ret = std::make_shared<ShaderPipelines>();
ShaderCachedData foundData = lookupData(tag);
@ -494,8 +492,7 @@ ShaderCacheManager::buildExtendedShader(const ShaderTag& tag, const std::string&
{
auto search = m_pipelineLookup.find(tag);
if (search != m_pipelineLookup.cend())
if (auto ret = search->second.lock())
return ret;
return search->second;
std::shared_ptr<ShaderPipelines> ret = std::make_shared<ShaderPipelines>();
ShaderCachedData foundData = lookupData(tag);
@ -545,8 +542,7 @@ ShaderCacheManager::buildExtendedShader(const ShaderTag& tag, const hecl::Fronte
{
auto search = m_pipelineLookup.find(tag);
if (search != m_pipelineLookup.cend())
if (auto ret = search->second.lock())
return ret;
return search->second;
std::shared_ptr<ShaderPipelines> ret = std::make_shared<ShaderPipelines>();
ShaderCachedData foundData = lookupData(tag);