Move combined image hiding logic into is_hidden.

This commit is contained in:
Hans-Kristian Arntzen 2016-09-10 16:20:19 +02:00
parent bcb5560109
commit 1b5ca8d868
4 changed files with 21 additions and 7 deletions

View File

@ -633,7 +633,7 @@ int main(int argc, char *argv[])
// Give the remapped combined samplers new names.
for (auto &remap : compiler->get_combined_image_samplers())
{
compiler->set_name(remap.combined_id, join("_Combined_", compiler->get_name(remap.image_id), "_",
compiler->set_name(remap.combined_id, join("_Combined", compiler->get_name(remap.image_id),
compiler->get_name(remap.sampler_id)));
}
}

View File

@ -382,6 +382,24 @@ bool Compiler::is_hidden_variable(const SPIRVariable &var, bool include_builtins
if ((is_builtin_variable(var) && !include_builtins) || var.remapped_variable)
return true;
// Combined image samplers are always considered active as they are "magic" variables.
if (find_if(begin(combined_image_samplers), end(combined_image_samplers), [&var](const CombinedImageSampler &samp) {
return samp.combined_id == var.self;
}) != end(combined_image_samplers))
{
return false;
}
// If we're remapping separate samplers and images, only emit the combined samplers.
if (!combined_image_samplers.empty())
{
auto &type = get<SPIRType>(var.basetype);
bool separate_image = type.basetype == SPIRType::Image && type.image.sampled == 1;
bool separate_sampler = type.basetype == SPIRType::Sampler;
if (separate_image || separate_sampler)
return true;
}
bool hidden = false;
if (check_active_interface_variables && storage_class_is_interface(var.storage))
hidden = active_interface_variables.find(var.self) == end(active_interface_variables);

View File

@ -263,6 +263,8 @@ public:
//
// The resulting samplers will be void of any decorations like name, descriptor sets and binding points,
// so this can be added before compile() if desired.
//
// Combined image samplers originating from this set are always considered active variables.
void build_combined_image_samplers();
// Gets a remapping for the combined image samplers.

View File

@ -1013,12 +1013,6 @@ void CompilerGLSL::emit_uniform(const SPIRVariable &var)
throw CompilerError("At least ESSL 3.10 required for shader image load store.");
}
// If we're remapping, only emit combined samplers.
bool separate_image = type.basetype == SPIRType::Image && type.image.sampled == 1;
bool separate_sampler = type.basetype == SPIRType::Sampler;
if (!combined_image_samplers.empty() && separate_image && separate_sampler)
return;
add_resource_name(var.self);
statement(layout_for_variable(var), "uniform ", variable_decl(var), ";");
}