Added ShaderStage macro in ShaderGen
This commit is contained in:
parent
3393a90127
commit
19df201ab5
2
CMCore
2
CMCore
@ -1 +1 @@
|
||||
Subproject commit ab0292d27e9825f1259688f78cf3bd02fbc9e785
|
||||
Subproject commit a1d1f6721c733b509243b3063f4898ef23ae0f75
|
@ -169,7 +169,7 @@ public:
|
||||
return(true);
|
||||
}
|
||||
|
||||
void BuildCommandBuffer(uint32 index)
|
||||
void BuildCommandBuffer(uint32 index) override
|
||||
{
|
||||
const CameraInfo &ci=GetCameraInfo();
|
||||
const ViewportInfo &vi=GetViewportInfo();
|
||||
@ -183,7 +183,7 @@ public:
|
||||
VulkanApplicationFramework::BuildCommandBuffer(index,render_list);
|
||||
}
|
||||
|
||||
void Resize(int w,int h)override
|
||||
void Resize(int w,int h) override
|
||||
{
|
||||
CameraAppFramework::Resize(w,h);
|
||||
|
||||
|
@ -5,12 +5,21 @@
|
||||
|
||||
#define STD_MTL_NAMESPACE_USING using namespace hgl::graph::mtl;
|
||||
|
||||
#define STD_MTL_FUNC_NAMESPACE_BEGIN namespace hgl{namespace graph{namespace mtl{namespace func{
|
||||
#define STD_MTL_FUNC_NAMESPACE_END }}}}
|
||||
|
||||
#define STD_MTL_FUNC NAMESPACE_USING using namespace hgl::graph::mtl::func;
|
||||
|
||||
|
||||
namespace hgl
|
||||
{
|
||||
namespace graph
|
||||
{
|
||||
namespace mtl
|
||||
{
|
||||
namespace func
|
||||
{
|
||||
}//namespace func
|
||||
}//namespace mtl
|
||||
}//namespace graph
|
||||
}//namespace hgl
|
||||
|
@ -79,14 +79,19 @@ SOURCE_GROUP("Standard Material" FILES ${STD_MTL_SOURCE})
|
||||
SOURCE_GROUP("Standard Material\\2D" FILES ${STD_MTL_2D_SOURCE_FILES})
|
||||
SOURCE_GROUP("Standard Material\\3D" FILES ${STD_MTL_3D_SOURCE_FILES})
|
||||
|
||||
SET(SHADER_LIBRARY_FILES ShaderLibrary.cpp ShaderLibrary.h)
|
||||
|
||||
SOURCE_GROUP("Shader Library" FILES ${SHADER_LIBRARY_FILES})
|
||||
|
||||
add_cm_library(ULRE.ShaderGen "ULRE" ${DESC_INFO_HEADER_FILES}
|
||||
${DESC_INFO_SOURCE_FILES}
|
||||
${MATERIAL_CREATE_INFO_HEADER_FILES}
|
||||
${MATERIAL_CREATE_INFO_SOURCE_FILES}
|
||||
${SHADER_CREATER_HEADER_FILES}
|
||||
${SHADER_CREATER_SOURCE_FILES}
|
||||
${GLSL_COMPILER_SOURCE}
|
||||
${GLSL_COMPILER_SOURCE}
|
||||
${SHADERGEN_COMMON_FILES}
|
||||
${SHADER_LIBRARY_FILES}
|
||||
${STD_MTL_SOURCE}
|
||||
${STD_MTL_2D_SOURCE_FILES}
|
||||
${STD_MTL_3D_SOURCE_FILES}
|
||||
|
@ -248,13 +248,7 @@ bool MaterialCreateInfo::CreateShader()
|
||||
{
|
||||
sc->AddOutput(VAT_UINT,mtl::func::MaterialInstanceID,Interpolation::Flat);
|
||||
|
||||
if(sc->GetShaderStage()==VK_SHADER_STAGE_VERTEX_BIT)
|
||||
sc->AddFunction(mtl::func::HandoverMI_VS);
|
||||
else
|
||||
if(sc->GetShaderStage()==VK_SHADER_STAGE_GEOMETRY_BIT)
|
||||
sc->AddFunction(mtl::func::HandoverMI_GS);
|
||||
else
|
||||
sc->AddFunction(mtl::func::HandoverMI);
|
||||
sc->AddFunction(mtl::func::HandoverMI);
|
||||
}
|
||||
|
||||
sc->CreateShader(last);
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include"common/MFCommon.h"
|
||||
|
||||
namespace hgl{namespace graph{
|
||||
|
||||
ShaderCreateInfo::ShaderCreateInfo(VkShaderStageFlagBits ss,MaterialDescriptorInfo *m)
|
||||
{
|
||||
shader_stage=ss;
|
||||
@ -158,10 +159,7 @@ void ShaderCreateInfo::SetMaterialInstance(UBODescriptor *ubo,const AnsiString &
|
||||
sdm->AddUBO(DescriptorSetType::PerMaterial,ubo);
|
||||
sdm->AddStruct(mtl::MaterialInstanceStruct);
|
||||
|
||||
if(shader_stage==VK_SHADER_STAGE_VERTEX_BIT)
|
||||
AddFunction(mtl::func::GetMI_VS);
|
||||
else
|
||||
AddFunction(mtl::func::GetMI);
|
||||
AddFunction(mtl::func::GetMI);
|
||||
|
||||
mi_codes=mi;
|
||||
}
|
||||
@ -377,7 +375,27 @@ bool ShaderCreateInfo::CreateShader(ShaderCreateInfo *last_sc)
|
||||
if(main_function.IsEmpty())
|
||||
return(false);
|
||||
|
||||
final_shader="#version 460 core\n";
|
||||
//@see VKShaderStage.cpp
|
||||
|
||||
final_shader=R"(#version 460 core
|
||||
|
||||
#define VertexShader 0x01
|
||||
#define TessControlShader 0x02
|
||||
#define TeseEvalShader 0x04
|
||||
#define GeometryShader 0x08
|
||||
#define FragmentShader 0x10
|
||||
#define ComputeShader 0x20
|
||||
#define TaskShader 0x40
|
||||
#define MeshShader 0x80
|
||||
|
||||
#define ShaderStage 0x)";
|
||||
|
||||
{
|
||||
char ss_hex_str[9];
|
||||
|
||||
final_shader+=utos(ss_hex_str,8,uint(shader_stage),16);
|
||||
final_shader+="\n";
|
||||
}
|
||||
|
||||
ProcDefine();
|
||||
|
||||
|
@ -16,38 +16,27 @@ mat4 GetLocalToWorld()
|
||||
|
||||
constexpr const char MaterialInstanceID[]="MaterialInstanceID";
|
||||
|
||||
constexpr const char HandoverMI_VS[]=R"(
|
||||
void HandoverMI()
|
||||
{
|
||||
Output.MaterialInstanceID=Assign.y;
|
||||
}
|
||||
)";
|
||||
|
||||
constexpr const char HandoverMI_GS[]=R"(
|
||||
void HandoverMI()
|
||||
{
|
||||
Output.MaterialInstanceID=Input[0].MaterialInstanceID;
|
||||
}
|
||||
)";
|
||||
|
||||
constexpr const char HandoverMI[]=R"(
|
||||
void HandoverMI()
|
||||
{
|
||||
#if ShaderStage == VertexShader
|
||||
Output.MaterialInstanceID=Assign.y;
|
||||
#elif ShaderStage == GeometryShader
|
||||
Output.MaterialInstanceID=Input[0].MaterialInstanceID;
|
||||
#else
|
||||
Output.MaterialInstanceID=Input.MaterialInstanceID;
|
||||
#endif
|
||||
}
|
||||
)";
|
||||
|
||||
constexpr const char GetMI_VS[]=R"(
|
||||
constexpr const char GetMI[]=R"(
|
||||
MaterialInstance GetMI()
|
||||
{
|
||||
#if ShaderStage == VertexShader
|
||||
return mtl.mi[Assign.y];
|
||||
}
|
||||
)";
|
||||
|
||||
constexpr const char GetMI[]=R"(
|
||||
MaterialInstance GetMI()
|
||||
{
|
||||
#else
|
||||
return mtl.mi[Input.MaterialInstanceID];
|
||||
#endif
|
||||
}
|
||||
)";
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user