Added KrCompileAllShaders and stub implementation

This commit is contained in:
2020-08-06 18:15:58 -07:00
parent b405c3014f
commit 78172b5abc
9 changed files with 77 additions and 10 deletions

View File

@@ -106,6 +106,7 @@ KRContext::KRContext(const KrInitializeInfo* initializeInfo)
#endif
createDeviceContexts();
glslang::InitializeProcess();
}
KRContext::~KRContext() {
@@ -170,6 +171,7 @@ KRContext::~KRContext() {
delete m_resourceMap;
m_resourceMap = NULL;
}
glslang::FinalizeProcess();
}
void KRContext::SetLogCallback(log_callback *log_callback, void *user_data)
@@ -493,6 +495,15 @@ KrResult KRContext::moveToBundle(const KrMoveToBundleInfo* moveToBundleInfo)
return resource->moveToBundle(bundle);
}
KrResult KRContext::compileAllShaders(const KrCompileAllShadersInfo* pCompileAllShadersInfo) {
bool success = m_pShaderManager->compileAll();
if (success) {
// TODO - Save log to a resource
return KR_SUCCESS;
}
return KR_ERROR_SHADER_COMPILE_FAILED;
}
KrResult KRContext::saveResource(const KrSaveResourceInfo* saveResourceInfo)
{
if (saveResourceInfo->resourceHandle < 0 || saveResourceInfo->resourceHandle >= m_resourceMapSize) {

View File

@@ -51,6 +51,8 @@ public:
KrResult unmapResource(const KrUnmapResourceInfo* unmapResourceInfo);
KrResult saveResource(const KrSaveResourceInfo* saveResourceInfo);
KrResult compileAllShaders(const KrCompileAllShadersInfo* pCompileAllShadersInfo);
KrResult createScene(const KrCreateSceneInfo* createSceneInfo);
KrResult findNodeByName(const KrFindNodeByNameInfo* pFindNodeByNameInfo);
KrResult findAdjacentNodes(const KrFindAdjacentNodesInfo* pFindAdjacentNodesInfo);

View File

@@ -34,6 +34,7 @@ using namespace kraken;
#include <stdio.h>
#include "../3rdparty/tinyxml2/tinyxml2.h"
#include "../3rdparty/glslang/glslang/Public/ShaderLang.h"
#if defined(__APPLE__)
#include <sys/mman.h>

View File

@@ -115,3 +115,8 @@ const unordered_map<std::string, KRShader *> &KRShaderManager::get(const std::st
return m_shaders[lower_extension];
}
bool KRShaderManager::compileAll()
{
return true;
}

View File

@@ -52,7 +52,8 @@ public:
KRShader *load(const std::string &name, const std::string &extension, KRDataBlock *data);
KRShader *get(const std::string &name, const std::string &extension);
bool compileAll();
const unordered_map<std::string, KRShader *> &get(const std::string &extension);

View File

@@ -114,6 +114,14 @@ KrResult KrMoveToBundle(const KrMoveToBundleInfo* pMoveToBundleInfo)
return sContext->moveToBundle(pMoveToBundleInfo);
}
KrResult KrCompileAllShaders(const KrCompileAllShadersInfo* pCompileAllShadersInfo)
{
if (!sContext) {
return KR_ERROR_NOT_INITIALIZED;
}
return sContext->compileAllShaders(pCompileAllShadersInfo);
}
KrResult KrCreateScene(const KrCreateSceneInfo* pCreateSceneInfo)
{
if (!sContext) {

View File

@@ -50,6 +50,7 @@ typedef enum {
KR_ERROR_VULKAN_REQUIRED,
KR_ERROR_VULKAN_SWAP_CHAIN,
KR_ERROR_NO_DEVICE,
KR_ERROR_SHADER_COMPILE_FAILED,
KR_ERROR_UNEXPECTED = 0x10000000,
KR_RESULT_MAX_ENUM = 0x7FFFFFFF
} KrResult;
@@ -69,6 +70,8 @@ typedef enum {
KR_STRUCTURE_TYPE_CREATE_BUNDLE,
KR_STRUCTURE_TYPE_MOVE_TO_BUNDLE,
KR_STRUCTURE_TYPE_COMPILE_ALL_SHADERS,
KR_STRUCTURE_TYPE_CREATE_SCENE = 0x00020000,
KR_STRUCTURE_TYPE_FIND_NODE_BY_NAME = 0x00030000,
@@ -165,6 +168,11 @@ typedef struct {
KrResourceMapIndex bundleHandle;
} KrMoveToBundleInfo;
typedef struct {
KrStructureType sType;
KrResourceMapIndex logHandle;
} KrCompileAllShadersInfo;
typedef struct {
KrStructureType sType;
const char* pSceneName;
@@ -395,6 +403,8 @@ KrResult KrCreateBundle(const KrCreateBundleInfo* pCreateBundleInfo);
KrResult KrMoveToBundle(const KrMoveToBundleInfo* pMoveToBundleInfo);
KrResult KrInitNodeInfo(KrNodeInfo* pNodeInfo, KrStructureType nodeType);
KrResult KrCompileAllShaders(const KrCompileAllShadersInfo* pCompileAllShadersInfo);
KrResult KrCreateScene(const KrCreateSceneInfo* pCreateSceneInfo);
KrResult KrFindNodeByName(const KrFindNodeByNameInfo* pFindNodeByNameInfo);
KrResult KrFindAdjacentNodes(const KrFindAdjacentNodesInfo* pFindAdjacentNodesInfo);