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
|
|
|
|
2023-03-15 11:09:51 +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
|
|
|
{
|
2023-05-06 22:19:50 +08:00
|
|
|
AnsiString main_codes="void main()\n{\n";
|
2023-03-06 14:06:20 +08:00
|
|
|
|
2023-03-15 11:09:51 +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-10 01:47:01 +08:00
|
|
|
|
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";
|
2023-03-10 01:47:01 +08:00
|
|
|
|
|
|
|
++o;
|
2023-03-06 14:06:20 +08:00
|
|
|
}
|
|
|
|
|
2023-03-13 21:58:27 +08:00
|
|
|
main_codes+="}";
|
2023-05-06 22:19:50 +08:00
|
|
|
|
|
|
|
AddFunction(main_codes);
|
2023-03-06 14:06:20 +08:00
|
|
|
}
|
2023-03-10 01:47:01 +08:00
|
|
|
|
2023-03-17 10:08:41 +08:00
|
|
|
bool ShaderCreateInfoFragment::ProcOutput()
|
2023-03-10 01:47:01 +08:00
|
|
|
{
|
2023-03-15 11:09:51 +08:00
|
|
|
const auto &output_list=sdm->GetShaderStageIO().output;
|
2023-03-10 01:47:01 +08:00
|
|
|
|
2023-03-17 21:06:05 +08:00
|
|
|
const ShaderAttribute *o=output_list.items;
|
2023-03-10 01:47:01 +08:00
|
|
|
|
2023-03-17 21:06:05 +08:00
|
|
|
for(uint i=0;i<output_list.count;i++)
|
2023-03-10 01:47:01 +08:00
|
|
|
{
|
|
|
|
final_shader+="layout(location=";
|
|
|
|
final_shader+=AnsiString::numberOf(i);
|
|
|
|
final_shader+=") out ";
|
2023-03-17 21:06:05 +08:00
|
|
|
final_shader+=GetShaderAttributeTypename(o);
|
2023-03-10 01:47:01 +08:00
|
|
|
final_shader+=" ";
|
2023-03-17 21:06:05 +08:00
|
|
|
final_shader+=o->name;
|
2023-03-10 01:47:01 +08:00
|
|
|
final_shader+=";\n";
|
|
|
|
|
|
|
|
++o;
|
|
|
|
}
|
|
|
|
|
|
|
|
return(true);
|
|
|
|
}
|
2023-03-21 18:05:48 +08:00
|
|
|
}}//namespace hgl::graph
|