ULRE/src/ShaderGen/ShaderCreateInfoFragment.cpp

53 lines
1.1 KiB
C++
Raw Normal View History

2023-03-17 10:08:41 +08:00
#include<hgl/shadergen/ShaderCreateInfoFragment.h>
2023-03-17 10:14:07 +08:00
#include<hgl/shadergen/ShaderDescriptorInfo.h>
2023-03-06 14:06:20 +08:00
2023-03-21 18:05:48 +08:00
namespace hgl{namespace graph{
2023-03-06 14:06:20 +08:00
using namespace hgl::graph;
2023-03-17 10:08:41 +08:00
void ShaderCreateInfoFragment::UseDefaultMain()
2023-03-06 14:06:20 +08:00
{
AnsiString main_codes="void main()\n{\n";
2023-03-06 14:06:20 +08:00
const auto &output_list=sdm->GetShaderStageIO().output;
2023-03-06 14:06:20 +08:00
2023-03-17 21:06:05 +08:00
const ShaderAttribute *o=output_list.items;
2023-03-17 21:06:05 +08:00
for(uint i=0;i<output_list.count;i++)
2023-03-06 14:06:20 +08:00
{
2023-03-13 21:58:27 +08:00
main_codes+="\t";
2023-03-17 21:06:05 +08:00
main_codes+=o->name;
2023-03-13 21:58:27 +08:00
main_codes+="=Get";
2023-03-17 21:06:05 +08:00
main_codes+=o->name;
2023-03-13 21:58:27 +08:00
main_codes+="();\n";
++o;
2023-03-06 14:06:20 +08:00
}
2023-03-13 21:58:27 +08:00
main_codes+="}";
AddFunction(main_codes);
2023-03-06 14:06:20 +08:00
}
2023-03-17 10:08:41 +08:00
bool ShaderCreateInfoFragment::ProcOutput()
{
const auto &output_list=sdm->GetShaderStageIO().output;
2023-03-17 21:06:05 +08:00
const ShaderAttribute *o=output_list.items;
2023-03-17 21:06:05 +08:00
for(uint i=0;i<output_list.count;i++)
{
final_shader+="layout(location=";
final_shader+=AnsiString::numberOf(i);
final_shader+=") out ";
2023-03-17 21:06:05 +08:00
final_shader+=GetShaderAttributeTypename(o);
final_shader+=" ";
2023-03-17 21:06:05 +08:00
final_shader+=o->name;
final_shader+=";\n";
++o;
}
return(true);
}
2023-03-21 18:05:48 +08:00
}}//namespace hgl::graph