Skip to content

Commit

Permalink
Group number is stored in ShaderResource, SamplerStateDesc and for co…
Browse files Browse the repository at this point in the history
…nstantBufferSlots.
  • Loading branch information
AndrewRichards-Code committed Aug 20, 2024
1 parent 06a7e73 commit 4877955
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
11 changes: 9 additions & 2 deletions CrossPlatform/Effect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ std::string Effect::GetConstantBufferNameAtSlot(int s)
{
for (const auto& i : constantBufferSlots)
{
if (i.second == s)
if (i.second.first == s)
return i.first;
}
return "";
Expand Down Expand Up @@ -1135,8 +1135,10 @@ bool Effect::Load(crossplatform::RenderPlatform *r, const char *filename_utf8)
const string &register_num =words[4];
const string &group_num =words[5];
int slot=atoi(register_num.c_str());
int group=atoi(group_num.c_str());
crossplatform::ShaderResource *res=new crossplatform::ShaderResource;
res->slot =slot;
res->group =group;
res->shaderResourceType=crossplatform::ShaderResourceType::ACCELERATION_STRUCTURE;
textureDetailsMap[name]=res;
textureResources[slot]=res;
Expand All @@ -1147,7 +1149,8 @@ bool Effect::Load(crossplatform::RenderPlatform *r, const char *filename_utf8)
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;
int group = atoi(constant_buffer_group.c_str());
constantBufferSlots[constant_buffer_name]={slot,group};
}
else if(is_equal(word,"texture"))
{
Expand All @@ -1158,13 +1161,15 @@ bool Effect::Load(crossplatform::RenderPlatform *r, const char *filename_utf8)
const string &group_num =words[5];
string is_array =words.size()>6?words[6]:"single";
int slot=atoi(register_num.c_str());
int group=atoi(group_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");
bool is_msaa=texture_dim.find("ms")!=string::npos;
bool rw=is_equal(read_write,"read_write");
bool ar=is_equal(is_array,"array");
crossplatform::ShaderResource *res=new crossplatform::ShaderResource;
res->slot =slot;
res->group =group;
res->dimensions =dim;
crossplatform::ShaderResourceType rt=crossplatform::ShaderResourceType::UNKNOWN;
if(!rw)
Expand Down Expand Up @@ -1356,11 +1361,13 @@ bool Effect::Load(crossplatform::RenderPlatform *r, const char *filename_utf8)
if(st.size()>4)
desc.depthComparison=(crossplatform::DepthComparison)toInt(st[4]);
desc.slot=reg;
desc.group=grp;
crossplatform::SamplerState *ss=renderPlatform->GetOrCreateSamplerStateByName(sampler_name.c_str(),&desc);
samplerStates[sampler_name]=ss;
samplerSlots[reg]=ss;
crossplatform::ShaderResource *res=new crossplatform::ShaderResource;
res->slot =reg;
res->group =grp;
res->shaderResourceType =ShaderResourceType::SAMPLER;
textureDetailsMap[sampler_name]=res;
}
Expand Down
3 changes: 2 additions & 1 deletion CrossPlatform/Effect.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ namespace platform
ShaderResourceType shaderResourceType=ShaderResourceType::UNKNOWN;
void* platform_shader_resource=nullptr;
int slot=-1;
int group=-1;
int dimensions=-1;
bool valid=false;
};
Expand Down Expand Up @@ -543,7 +544,7 @@ namespace platform
phmap::flat_hash_map<std::string,crossplatform::RenderState *> blendStates;
phmap::flat_hash_map<std::string,crossplatform::RenderState *> rasterizerStates;
phmap::flat_hash_map<std::string, crossplatform::RenderState *> rtFormatStates;
phmap::flat_hash_map<std::string, int> constantBufferSlots;
phmap::flat_hash_map<std::string, std::pair<int, int>> constantBufferSlots; //name -> {slot, group}
SamplerStateAssignmentMap samplerSlots; // The slots for THIS effect - may not be the sampler's defaults.
const ShaderResource *GetTextureDetails(const char *name);
virtual void PostLoad(){}
Expand Down
1 change: 1 addition & 0 deletions CrossPlatform/Texture.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ namespace platform
Filtering filtering;
DepthComparison depthComparison;
int slot; // register slot
int group; // group number
};

enum class VideoTextureType
Expand Down

0 comments on commit 4877955

Please sign in to comment.