added sampler parse in MaterialFileLoader.cpp

This commit is contained in:
HuYingzhuo(hugo/hyzboy) 2023-10-10 14:46:20 +08:00
parent bead8128b7
commit 3dd308aff1
2 changed files with 43 additions and 0 deletions

View File

@ -1,6 +1,7 @@
#pragma once
#include<hgl/type/Map.h>
#include<hgl/graph/VKShaderStage.h>
#include<hgl/graph/VKSamplerType.h>
namespace material_file
{
@ -24,6 +25,13 @@ namespace material_file
uint32_t shader_stage_flag_bits;
};
struct SamplerData
{
char name[SHADER_RESOURCE_NAME_MAX_LENGTH];
SamplerType type;
};
struct ShaderData
{
VkShaderStageFlagBits shader_stage;
@ -33,6 +41,8 @@ namespace material_file
List<UniformAttrib> output;
List<SamplerData> sampler;
public:
ShaderData(VkShaderStageFlagBits ss)
@ -76,12 +86,15 @@ namespace material_file
ObjectMap<VkShaderStageFlagBits,ShaderData> shader;
uint32_t shader_stage_flag_bit;
public:
MaterialFileData(char *d,int dl)
{
data=d;
data_length=dl;
shader_stage_flag_bit=0;
}
~MaterialFileData()

View File

@ -2,6 +2,7 @@
#include<hgl/graph/mtl/Material2DCreateConfig.h>
#include<hgl/graph/mtl/Material3DCreateConfig.h>
#include<hgl/graph/VKShaderStage.h>
#include<hgl/graph/VKSamplerType.h>
#include<hgl/io/TextInputStream.h>
#include<hgl/filesystem/FileSystem.h>
@ -295,6 +296,33 @@ namespace
{
output=true;
}
else
if(hgl::stricmp(text,"sampler",7)==0)
{
const char *sp=text;
while(*text!=' '&&*text!='\t')++text;
SamplerType st=ParseSamplerType(sp,text-sp);
RANGE_CHECK_RETURN_FALSE(st);
while(!hgl::iscodechar(*text))++text;
sp=text;
while(hgl::iscodechar(*text))++text;
SamplerData sd;
sd.type=st;
hgl::strcpy(sd.name,SHADER_RESOURCE_NAME_MAX_LENGTH,sp,text-sp);
shader_data->sampler.Add(sd);
}
else
{
}
return(true);
}
@ -445,6 +473,8 @@ namespace
return(false);
mfd->shader.Add(sd->GetShaderStage(),sd);
mfd->shader_stage_flag_bit|=sd->GetShaderStage();
}
else
{