diff --git a/hecl/extern/Athena b/hecl/extern/Athena index df43b72f8..18e94dbc5 160000 --- a/hecl/extern/Athena +++ b/hecl/extern/Athena @@ -1 +1 @@ -Subproject commit df43b72f8ac860c6662896cd97498a4091a6174d +Subproject commit 18e94dbc54cf1e88d7c5b697e96b05a1f583edee diff --git a/hecl/extern/libBoo b/hecl/extern/libBoo index 742e062cf..b97ad76c4 160000 --- a/hecl/extern/libBoo +++ b/hecl/extern/libBoo @@ -1 +1 @@ -Subproject commit 742e062cf2f128baeb9533cd7fd41f4acb072001 +Subproject commit b97ad76c45b4965f3dd9f499e5975738714f5fa8 diff --git a/hecl/include/HECL/Backend/GX.hpp b/hecl/include/HECL/Backend/GX.hpp index 356d11e26..c6d7c11ca 100644 --- a/hecl/include/HECL/Backend/GX.hpp +++ b/hecl/include/HECL/Backend/GX.hpp @@ -351,7 +351,9 @@ struct GX : IBackend } } - for (int i=0 ; i<3 ; ++i) + /* Allocate from back for compatibility with Retro's + * extended shader arithmetic use */ + for (int i=2 ; i>=0 ; --i) if (!(regMask & (1 << i))) return i; @@ -379,7 +381,9 @@ struct GX : IBackend } } - for (int i=0 ; i<3 ; ++i) + /* Allocate from back for compatibility with Retro's + * extended shader arithmetic use */ + for (int i=2 ; i>=0 ; --i) if (!(regMask & (1 << i))) return i; diff --git a/hecl/include/HECL/Runtime.hpp b/hecl/include/HECL/Runtime.hpp index 6f3775c7b..e0601da8a 100644 --- a/hecl/include/HECL/Runtime.hpp +++ b/hecl/include/HECL/Runtime.hpp @@ -10,6 +10,8 @@ namespace HECL { +struct HMDLMeta; + namespace Runtime { @@ -75,6 +77,9 @@ public: bool getDepthWrite() const {return m_depthWrite;} bool getBackfaceCulling() const {return m_backfaceCulling;} uint64_t getMetaData() const {return m_meta;} + + /* For shader constructors that require vertex format up-front (HLSL) */ + boo::IVertexFormat* newVertexFormat(boo::IGraphicsDataFactory* factory) const; }; /** @@ -217,11 +222,15 @@ struct HMDLData { boo::IGraphicsBufferS* m_vbo; boo::IGraphicsBufferS* m_ibo; - boo::IVertexFormat* m_vtxFmt; + boo::IVertexFormat* m_vtxFmt = nullptr; HMDLData(boo::IGraphicsDataFactory* factory, const void* metaData, const void* vbo, const void* ibo); + /* For binding constructors that require vertex format up front (GLSL) */ + static boo::IVertexFormat* NewVertexFormat(boo::IGraphicsDataFactory* factory, const HMDLMeta& meta, + boo::IGraphicsBuffer* vbo=nullptr, boo::IGraphicsBuffer* ibo=nullptr); + boo::IShaderDataBinding* newShaderDataBindng(boo::IGraphicsDataFactory* factory, boo::IShaderPipeline* shader, size_t ubufCount, boo::IGraphicsBuffer** ubufs, diff --git a/hecl/lib/Backend/CMakeLists.txt b/hecl/lib/Backend/CMakeLists.txt index b50d03d22..3938d4ec8 100644 --- a/hecl/lib/Backend/CMakeLists.txt +++ b/hecl/lib/Backend/CMakeLists.txt @@ -1,4 +1,5 @@ add_library(HECLBackend GX.cpp ProgrammableCommon.cpp - GLSL.cpp) + GLSL.cpp + HLSL.cpp) diff --git a/hecl/lib/CMakeLists.txt b/hecl/lib/CMakeLists.txt index 4aa49b59d..6b80f9802 100644 --- a/hecl/lib/CMakeLists.txt +++ b/hecl/lib/CMakeLists.txt @@ -21,6 +21,7 @@ add_library(HECLCommon ../include/HECL/Backend/GX.hpp ../include/HECL/Backend/ProgrammableCommon.hpp ../include/HECL/Backend/GLSL.hpp + ../include/HECL/Backend/HLSL.hpp ../include/HECL/Frontend.hpp ../include/HECL/Database.hpp ../include/HECL/Runtime.hpp diff --git a/hecl/lib/Frontend/Parser.cpp b/hecl/lib/Frontend/Parser.cpp index 4b385013f..bd767c85b 100644 --- a/hecl/lib/Frontend/Parser.cpp +++ b/hecl/lib/Frontend/Parser.cpp @@ -10,17 +10,17 @@ namespace Frontend void Parser::skipWhitespace(std::string::const_iterator& it) { - while (true) + while (it != m_source->cend()) { - while (isspace(*it) && it != m_source->cend()) + while (it != m_source->cend() && isspace(*it)) ++it; /* Skip comment line */ - if (*it == '#') + if (it != m_source->cend() && *it == '#') { - while (*it != '\n' && it != m_source->cend()) + while (it != m_source->cend() && *it != '\n') ++it; - if (*it == '\n') + if (it != m_source->cend() && *it == '\n') ++it; continue; } diff --git a/hecl/lib/Runtime/HMDL.cpp b/hecl/lib/Runtime/HMDL.cpp index 53031e1d6..ff572b8cf 100644 --- a/hecl/lib/Runtime/HMDL.cpp +++ b/hecl/lib/Runtime/HMDL.cpp @@ -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 vdescs(new boo::VertexElementDescriptor[elemCount]); for (size_t i=0 ; inewVertexFormat(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 vdescs(new boo::VertexElementDescriptor[elemCount]); + for (size_t i=0 ; inewVertexFormat(elemCount, vdescs.get()); } } diff --git a/hecl/lib/Runtime/ShaderCacheManager.cpp b/hecl/lib/Runtime/ShaderCacheManager.cpp index 83eb61c3b..386a1db72 100644 --- a/hecl/lib/Runtime/ShaderCacheManager.cpp +++ b/hecl/lib/Runtime/ShaderCacheManager.cpp @@ -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();