2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-08 15:04:56 +00:00

Working HECL shader generation on D3D11/12

This commit is contained in:
Jack Andersen
2015-11-17 20:16:08 -10:00
parent 05f3854449
commit 6387b420ae
9 changed files with 79 additions and 15 deletions

View File

@@ -22,12 +22,20 @@ HMDLData::HMDLData(boo::IGraphicsDataFactory* factory,
m_vbo = factory->newStaticBuffer(boo::BufferUseVertex, vbo, meta.vertStride, meta.vertCount);
m_ibo = factory->newStaticBuffer(boo::BufferUseIndex, ibo, 4, meta.indexCount);
if (factory->bindingNeedsVertexFormat())
m_vtxFmt = NewVertexFormat(factory, meta, m_vbo, m_ibo);
}
/* For binding constructors that require vertex format up front (GLSL) */
boo::IVertexFormat* HMDLData::NewVertexFormat(boo::IGraphicsDataFactory* factory, const HMDLMeta& meta,
boo::IGraphicsBuffer* vbo, boo::IGraphicsBuffer* ibo)
{
size_t elemCount = 2 + meta.colorCount + meta.uvCount + meta.weightCount;
std::unique_ptr<boo::VertexElementDescriptor[]> vdescs(new boo::VertexElementDescriptor[elemCount]);
for (size_t i=0 ; i<elemCount ; ++i)
{
vdescs[i].vertBuffer = m_vbo;
vdescs[i].indexBuffer = m_ibo;
vdescs[i].vertBuffer = vbo;
vdescs[i].indexBuffer = ibo;
}
vdescs[0].semantic = boo::VertexSemanticPosition;
@@ -52,7 +60,43 @@ HMDLData::HMDLData(boo::IGraphicsDataFactory* factory,
vdescs[e].semanticIdx = i;
}
m_vtxFmt = factory->newVertexFormat(elemCount, vdescs.get());
return factory->newVertexFormat(elemCount, vdescs.get());
}
/* For shader constructors that require vertex format up-front (HLSL) */
boo::IVertexFormat* ShaderTag::newVertexFormat(boo::IGraphicsDataFactory *factory) const
{
size_t elemCount = 2 + m_colorCount + m_uvCount + m_weightCount;
std::unique_ptr<boo::VertexElementDescriptor[]> vdescs(new boo::VertexElementDescriptor[elemCount]);
for (size_t i=0 ; i<elemCount ; ++i)
{
vdescs[i].vertBuffer = nullptr;
vdescs[i].indexBuffer = nullptr;
}
vdescs[0].semantic = boo::VertexSemanticPosition;
vdescs[1].semantic = boo::VertexSemanticNormal;
size_t e = 2;
for (size_t i=0 ; i<m_colorCount ; ++i, ++e)
{
vdescs[e].semantic = boo::VertexSemanticColor;
vdescs[e].semanticIdx = i;
}
for (size_t i=0 ; i<m_uvCount ; ++i, ++e)
{
vdescs[e].semantic = boo::VertexSemanticUV;
vdescs[e].semanticIdx = i;
}
for (size_t i=0 ; i<m_weightCount ; ++i, ++e)
{
vdescs[e].semantic = boo::VertexSemanticWeight;
vdescs[e].semanticIdx = i;
}
return factory->newVertexFormat(elemCount, vdescs.get());
}
}

View File

@@ -12,6 +12,7 @@ namespace HECL
namespace Runtime
{
IShaderBackendFactory* _NewGLSLBackendFactory(boo::IGraphicsDataFactory* gfxFactory);
IShaderBackendFactory* _NewHLSLBackendFactory(boo::IGraphicsDataFactory* gfxFactory);
static LogVisor::LogModule Log("ShaderCacheManager");
static uint64_t IDX_MAGIC = SBig(uint64_t(0xDEADFEEDC001D00D));
@@ -109,8 +110,12 @@ ShaderCacheManager::ShaderCacheManager(const FileStoreManager& storeMgr,
case boo::IGraphicsDataFactory::PlatformOGL:
m_factory.reset(_NewGLSLBackendFactory(gfxFactory));
break;
case boo::IGraphicsDataFactory::PlatformD3D11:
case boo::IGraphicsDataFactory::PlatformD3D12:
m_factory.reset(_NewHLSLBackendFactory(gfxFactory));
break;
default:
Log.report(LogVisor::FatalError, "unsupported backend %s", gfxFactory->platformName());
Log.report(LogVisor::FatalError, _S("unsupported backend %s"), gfxFactory->platformName());
}
reload();