Skip to content

Commit

Permalink
Group number is set in the .sfxo and read in by the Effect::Load()
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewRichards-Code committed Aug 8, 2024
1 parent 1da9581 commit 06a7e73
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
7 changes: 4 additions & 3 deletions Applications/Sfx/SfxEffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1315,7 +1315,7 @@ bool Effect::Save(string sfxFilename,string sfxoFilename)

for (auto b : m_constantBuffers)
{
outstr << "constant_buffer " << b.first << " "<<GenerateConstantBufferSlot(b.second->slot,false)<<std::endl;
outstr << "constant_buffer " << b.first << " " << GenerateConstantBufferSlot(b.second->slot, false) << " g" << b.second->group_num << std::endl;
usedConstantBufferSlots.insert(b.second->slot);
}

Expand Down Expand Up @@ -1352,7 +1352,7 @@ bool Effect::Save(string sfxFilename,string sfxoFilename)
if (is_msaa)
outstr << "ms";

outstr << " " << rw << " " << (writeable?GenerateTextureWriteSlot(dt->slot,false):GenerateTextureSlot(dt->slot,false))<< " " << ar << std::endl;
outstr << " " << rw << " " << (writeable ? GenerateTextureWriteSlot(dt->slot, false) : GenerateTextureSlot(dt->slot, false)) << " g" << t->second->group_num << " " << ar << std::endl;
if (dt->slot >= 32)
{
std::cerr << sfxFilename.c_str() << "(0): error: by default, only 16 texture slots are enabled in Gnmx." << std::endl;
Expand All @@ -1370,7 +1370,7 @@ bool Effect::Save(string sfxFilename,string sfxoFilename)
continue;
NamedConstantBuffer *dt = static_cast<NamedConstantBuffer*>(t->second);
outstr << "namedconstantbuffer " << t->first << " ";
outstr << " " <<dt->slot<< std::endl;
outstr << " " << dt->slot << " g" << t->second->group_num << std::endl;
}
// Add samplers to the effect file
for (auto t = declarations.begin(); t != declarations.end(); ++t)
Expand All @@ -1382,6 +1382,7 @@ bool Effect::Save(string sfxFilename,string sfxoFilename)
SamplerState *ss = (SamplerState *)t->second;
outstr << "SamplerState " << t->first << " "
<< GenerateSamplerSlot(ss->register_number,false)
<< " g" << t->second->group_num
<< "," << ToString(ss->Filter)
<< "," << ToString(ss->AddressU)
<< "," << ToString(ss->AddressV)
Expand Down
14 changes: 10 additions & 4 deletions CrossPlatform/Effect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1133,6 +1133,7 @@ bool Effect::Load(crossplatform::RenderPlatform *r, const char *filename_utf8)
{
const string &name =words[1];
const string &register_num =words[4];
const string &group_num =words[5];
int slot=atoi(register_num.c_str());
crossplatform::ShaderResource *res=new crossplatform::ShaderResource;
res->slot =slot;
Expand All @@ -1144,6 +1145,7 @@ bool Effect::Load(crossplatform::RenderPlatform *r, const char *filename_utf8)
{
const string &constant_buffer_name = words[1];
const string &constant_buffer_slot = words[2];
const string &constant_buffer_group = words[3];
int slot = atoi(constant_buffer_slot.c_str());
constantBufferSlots[constant_buffer_name]=slot;
}
Expand All @@ -1153,7 +1155,8 @@ bool Effect::Load(crossplatform::RenderPlatform *r, const char *filename_utf8)
const string &texture_dim =words[2];
const string &read_write =words[3];
const string &register_num =words[4];
string is_array =words.size()>5?words[5]:"single";
const string &group_num =words[5];
string is_array =words.size()>6?words[6]:"single";
int slot=atoi(register_num.c_str());
int dim=is_equal(texture_dim,"3d")||is_equal(texture_dim,"3dms")?3:2;
bool is_cubemap=is_equal(texture_dim,"cubemap")||is_equal(texture_dim,"cubemapms");
Expand Down Expand Up @@ -1334,12 +1337,15 @@ bool Effect::Load(crossplatform::RenderPlatform *r, const char *filename_utf8)
}
else if(is_equal(word, "SamplerState"))
{
//SamplerState clampSamplerState 9,MIN_MAG_MIP_LINEAR,CLAMP,CLAMP,CLAMP,
//SamplerState clampSamplerState 9 g0,MIN_MAG_MIP_LINEAR,CLAMP,CLAMP,CLAMP,
size_t sp2=line.find(" ",sp+1);
size_t sp3=line.find(" ",sp2+1);
size_t comma=(int)std::min(line.length(),line.find(",",sp3+1));
string sampler_name = line.substr(sp + 1, sp2 - sp - 1);
size_t comma=(int)std::min(line.length(),line.find(",",sp2+1));
string register_num = line.substr(sp2 + 1, comma - sp2 - 1);
string register_num = line.substr(sp2 + 1, sp3 - sp2 - 1);
string group_num = line.substr(sp3 + 2, comma - sp3 - 2);
int reg=atoi(register_num.c_str());
int grp=atoi(group_num.c_str());
platform::crossplatform::SamplerStateDesc desc;
string state=line.substr(comma+1,line.length()-comma-1);
vector<string> st=platform::core::split(state,',');
Expand Down

0 comments on commit 06a7e73

Please sign in to comment.