upgrade ShaderModuleMap, auto detect kind of ShaderModule
This commit is contained in:
parent
5427d10e8d
commit
e7f0009908
@ -1 +1 @@
|
|||||||
Subproject commit c2a18897ee57706681ed8b803187a129df5b3e40
|
Subproject commit 1e14c1b01dd9b1e6590110cdf5fb239da30d00c1
|
2
CMCore
2
CMCore
@ -1 +1 @@
|
|||||||
Subproject commit 80d1e17dcb28bba754a826044462bf08ab81de32
|
Subproject commit 7927586bd1e36f0e0d7dd6d1e944570bd5121e19
|
@ -1 +1 @@
|
|||||||
Subproject commit 12590b9c6420114154696d23dab0ca14e0baae21
|
Subproject commit 1209d487ba12af9cab085c18aa4c3722d8e8f6d0
|
@ -1 +1 @@
|
|||||||
Subproject commit 762124c15723d71fd9d2b056d91ff4bf7737fd59
|
Subproject commit 384727bf3ed298d9aaaa2454afa910568039f1ff
|
23
inc/hgl/graph/vulkan/ShaderModuleMap.h
Normal file
23
inc/hgl/graph/vulkan/ShaderModuleMap.h
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#ifndef HGL_GRAPH_VULKAN_SHADER_MODULE_MAP_INCLUDE
|
||||||
|
#define HGL_GRAPH_VULKAN_SHADER_MODULE_MAP_INCLUDE
|
||||||
|
|
||||||
|
#include<hgl/type/Map.h>
|
||||||
|
#include<hgl/graph/vulkan/VKNamespace.h>
|
||||||
|
|
||||||
|
VK_NAMESPACE_BEGIN
|
||||||
|
|
||||||
|
using namespace hgl;
|
||||||
|
|
||||||
|
class ShaderModule;
|
||||||
|
|
||||||
|
class ShaderModuleMap:public Map<VkShaderStageFlagBits,const ShaderModule *>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
using Map<VkShaderStageFlagBits,const ShaderModule *>::Map;
|
||||||
|
~ShaderModuleMap()=default;
|
||||||
|
|
||||||
|
bool Add(const ShaderModule *sm);
|
||||||
|
};//class ShaderModuleMap:public Map<VkShaderStageFlagBits,const ShaderModule *>
|
||||||
|
VK_NAMESPACE_END
|
||||||
|
#endif//HGL_GRAPH_VULKAN_SHADER_MODULE_MAP_INCLUDE
|
@ -49,6 +49,7 @@ class Semaphore;
|
|||||||
|
|
||||||
struct ShaderStage;
|
struct ShaderStage;
|
||||||
|
|
||||||
|
class ShaderModuleMap;
|
||||||
class ShaderModule;
|
class ShaderModule;
|
||||||
class ShaderModuleManage;
|
class ShaderModuleManage;
|
||||||
class VertexShaderModule;
|
class VertexShaderModule;
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
#include<hgl/type/String.h>
|
#include<hgl/type/String.h>
|
||||||
VK_NAMESPACE_BEGIN
|
VK_NAMESPACE_BEGIN
|
||||||
class DescriptorSetLayoutCreater;
|
class DescriptorSetLayoutCreater;
|
||||||
using ShaderModuleMap=hgl::Map<VkShaderStageFlagBits,const ShaderModule *>;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 材质类<br>
|
* 材质类<br>
|
||||||
|
@ -37,6 +37,16 @@ public:
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
const VkShaderStageFlagBits GetStage ()const{return stage_create_info->stage;}
|
const VkShaderStageFlagBits GetStage ()const{return stage_create_info->stage;}
|
||||||
|
|
||||||
|
const bool IsVertex ()const{return stage_create_info->stage==VK_SHADER_STAGE_VERTEX_BIT;}
|
||||||
|
const bool IsTessControl ()const{return stage_create_info->stage==VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT;}
|
||||||
|
const bool IsTessEval ()const{return stage_create_info->stage==VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT;}
|
||||||
|
const bool IsGeometry ()const{return stage_create_info->stage==VK_SHADER_STAGE_GEOMETRY_BIT;}
|
||||||
|
const bool IsFragment ()const{return stage_create_info->stage==VK_SHADER_STAGE_FRAGMENT_BIT;}
|
||||||
|
const bool IsCompute ()const{return stage_create_info->stage==VK_SHADER_STAGE_COMPUTE_BIT;}
|
||||||
|
const bool IsTask ()const{return stage_create_info->stage==VK_SHADER_STAGE_TASK_BIT_NV;}
|
||||||
|
const bool IsMesh ()const{return stage_create_info->stage==VK_SHADER_STAGE_MESH_BIT_NV;}
|
||||||
|
|
||||||
const VkPipelineShaderStageCreateInfo * GetCreateInfo ()const{return stage_create_info;}
|
const VkPipelineShaderStageCreateInfo * GetCreateInfo ()const{return stage_create_info;}
|
||||||
|
|
||||||
const int GetBinding (VkDescriptorType desc_type,const AnsiString &name)const
|
const int GetBinding (VkDescriptorType desc_type,const AnsiString &name)const
|
||||||
|
@ -59,6 +59,8 @@ SET(VK_TEXTURE_SOURCE ${RD_INCLUDE_PATH}/VKImageView.h
|
|||||||
|
|
||||||
SET(VK_MATERIAL_SOURCE ${RD_INCLUDE_PATH}/VKMaterial.h
|
SET(VK_MATERIAL_SOURCE ${RD_INCLUDE_PATH}/VKMaterial.h
|
||||||
${RD_INCLUDE_PATH}/VKMaterialInstance.h
|
${RD_INCLUDE_PATH}/VKMaterialInstance.h
|
||||||
|
${RD_INCLUDE_PATH}/ShaderModuleMap.h
|
||||||
|
ShaderModuleMap.cpp
|
||||||
VKMaterial.cpp
|
VKMaterial.cpp
|
||||||
VKMaterialInstance.cpp)
|
VKMaterialInstance.cpp)
|
||||||
|
|
||||||
|
15
src/RenderDevice/Vulkan/ShaderModuleMap.cpp
Normal file
15
src/RenderDevice/Vulkan/ShaderModuleMap.cpp
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#include<hgl/graph/vulkan/ShaderModuleMap.h>
|
||||||
|
#include<hgl/graph/vulkan/VKShaderModule.h>
|
||||||
|
|
||||||
|
VK_NAMESPACE_BEGIN
|
||||||
|
bool ShaderModuleMap::Add(const ShaderModule *sm)
|
||||||
|
{
|
||||||
|
if(!sm)return(false);
|
||||||
|
|
||||||
|
const VkShaderStageFlagBits stage=sm->GetStage();
|
||||||
|
|
||||||
|
if(this->KeyExist(stage))return(false);
|
||||||
|
|
||||||
|
return this->Map::Add(stage,sm);
|
||||||
|
}
|
||||||
|
VK_NAMESPACE_END
|
@ -2,6 +2,7 @@
|
|||||||
#include<hgl/graph/vulkan/VKDevice.h>
|
#include<hgl/graph/vulkan/VKDevice.h>
|
||||||
#include<hgl/graph/vulkan/VKDescriptorSets.h>
|
#include<hgl/graph/vulkan/VKDescriptorSets.h>
|
||||||
#include<hgl/graph/vulkan/VKShaderModule.h>
|
#include<hgl/graph/vulkan/VKShaderModule.h>
|
||||||
|
#include<hgl/graph/vulkan/ShaderModuleMap.h>
|
||||||
#include<hgl/graph/vulkan/VKVertexAttributeBinding.h>
|
#include<hgl/graph/vulkan/VKVertexAttributeBinding.h>
|
||||||
#include<hgl/graph/vulkan/VKRenderable.h>
|
#include<hgl/graph/vulkan/VKRenderable.h>
|
||||||
#include<hgl/graph/vulkan/VKBuffer.h>
|
#include<hgl/graph/vulkan/VKBuffer.h>
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#include<hgl/graph/vulkan/VKShaderModule.h>
|
#include<hgl/graph/vulkan/VKShaderModule.h>
|
||||||
#include<hgl/graph/vulkan/VKMaterial.h>
|
#include<hgl/graph/vulkan/VKMaterial.h>
|
||||||
#include<hgl/graph/vulkan/VKDevice.h>
|
#include<hgl/graph/vulkan/VKDevice.h>
|
||||||
|
#include<hgl/graph/vulkan/ShaderModuleMap.h>
|
||||||
#include<hgl/graph/shader/ShaderResource.h>
|
#include<hgl/graph/shader/ShaderResource.h>
|
||||||
#include<hgl/filesystem/FileSystem.h>
|
#include<hgl/filesystem/FileSystem.h>
|
||||||
|
|
||||||
@ -104,13 +105,13 @@ Material *ShaderModuleManage::CreateMaterial(const VertexShaderModule *vertex_sh
|
|||||||
if(!vertex_shader_module||!fragment_shader_module)
|
if(!vertex_shader_module||!fragment_shader_module)
|
||||||
return(nullptr);
|
return(nullptr);
|
||||||
|
|
||||||
if(vertex_shader_module->GetStage()!=VK_SHADER_STAGE_VERTEX_BIT)return(nullptr);
|
if(!vertex_shader_module->IsVertex())return(nullptr);
|
||||||
if(fragment_shader_module->GetStage()!=VK_SHADER_STAGE_FRAGMENT_BIT)return(nullptr);
|
if(!fragment_shader_module->IsFragment())return(nullptr);
|
||||||
|
|
||||||
ShaderModuleMap *smm=new ShaderModuleMap;
|
ShaderModuleMap *smm=new ShaderModuleMap;
|
||||||
|
|
||||||
smm->Add(VK_SHADER_STAGE_VERTEX_BIT,vertex_shader_module);
|
smm->Add(vertex_shader_module);
|
||||||
smm->Add(VK_SHADER_STAGE_FRAGMENT_BIT,fragment_shader_module);
|
smm->Add(fragment_shader_module);
|
||||||
|
|
||||||
return(VK_NAMESPACE::CreateMaterial(device,smm));
|
return(VK_NAMESPACE::CreateMaterial(device,smm));
|
||||||
}
|
}
|
||||||
@ -122,15 +123,15 @@ Material *ShaderModuleManage::CreateMaterial(const VertexShaderModule *vertex_sh
|
|||||||
||!fragment_shader_module)
|
||!fragment_shader_module)
|
||||||
return(nullptr);
|
return(nullptr);
|
||||||
|
|
||||||
if(vertex_shader_module->GetStage()!=VK_SHADER_STAGE_VERTEX_BIT)return(nullptr);
|
if(!vertex_shader_module->IsVertex())return(nullptr);
|
||||||
if(geometry_shader_module->GetStage()!=VK_SHADER_STAGE_GEOMETRY_BIT)return(nullptr);
|
if(!geometry_shader_module->IsGeometry())return(nullptr);
|
||||||
if(fragment_shader_module->GetStage()!=VK_SHADER_STAGE_FRAGMENT_BIT)return(nullptr);
|
if(!fragment_shader_module->IsFragment())return(nullptr);
|
||||||
|
|
||||||
ShaderModuleMap *smm=new ShaderModuleMap;
|
ShaderModuleMap *smm=new ShaderModuleMap;
|
||||||
|
|
||||||
smm->Add(VK_SHADER_STAGE_VERTEX_BIT,vertex_shader_module);
|
smm->Add(vertex_shader_module);
|
||||||
smm->Add(VK_SHADER_STAGE_GEOMETRY_BIT,geometry_shader_module);
|
smm->Add(geometry_shader_module);
|
||||||
smm->Add(VK_SHADER_STAGE_FRAGMENT_BIT,fragment_shader_module);
|
smm->Add(fragment_shader_module);
|
||||||
|
|
||||||
return(VK_NAMESPACE::CreateMaterial(device,smm));
|
return(VK_NAMESPACE::CreateMaterial(device,smm));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user