Consistently use "image" nomenclature for separate images.

This commit is contained in:
Hans-Kristian Arntzen 2016-09-11 13:47:06 +02:00
parent 3c5f55cde1
commit 378fbe8b92
4 changed files with 29 additions and 29 deletions

View File

@ -317,7 +317,7 @@ static void print_resources(const Compiler &compiler, const ShaderResources &res
print_resources(compiler, "inputs", res.stage_inputs);
print_resources(compiler, "outputs", res.stage_outputs);
print_resources(compiler, "textures", res.sampled_images);
print_resources(compiler, "separate textures", res.separate_images);
print_resources(compiler, "separate images", res.separate_images);
print_resources(compiler, "separate samplers", res.separate_samplers);
print_resources(compiler, "images", res.storage_images);
print_resources(compiler, "ssbos", res.storage_buffers);

View File

@ -449,9 +449,9 @@ struct SPIRFunction : IVariant
struct CombinedImageSamplerParameter
{
uint32_t id;
uint32_t texture_id;
uint32_t image_id;
uint32_t sampler_id;
bool global_texture;
bool global_image;
bool global_sampler;
};

View File

@ -2383,42 +2383,42 @@ bool Compiler::CombinedImageSamplerHandler::end_function_scope(const uint32_t *a
{
for (auto &param : params)
{
uint32_t texture_id = param.global_texture ? param.texture_id : args[param.texture_id];
uint32_t image_id = param.global_image ? param.image_id : args[param.image_id];
uint32_t sampler_id = param.global_sampler ? param.sampler_id : args[param.sampler_id];
auto *t = compiler.maybe_get_backing_variable(texture_id);
auto *i = compiler.maybe_get_backing_variable(image_id);
auto *s = compiler.maybe_get_backing_variable(sampler_id);
if (t)
texture_id = t->self;
if (i)
image_id = i->self;
if (s)
sampler_id = s->self;
register_combined_image_sampler(caller, texture_id, sampler_id);
register_combined_image_sampler(caller, image_id, sampler_id);
}
}
return true;
}
void Compiler::CombinedImageSamplerHandler::register_combined_image_sampler(SPIRFunction &caller, uint32_t texture_id,
void Compiler::CombinedImageSamplerHandler::register_combined_image_sampler(SPIRFunction &caller, uint32_t image_id,
uint32_t sampler_id)
{
// We now have a texture ID and a sampler ID which will either be found as a global
// or a parameter in our own function. If both are global, they will not need a parameter,
// otherwise, add it to our list.
SPIRFunction::CombinedImageSamplerParameter param = {
0u, texture_id, sampler_id, true, true,
0u, image_id, sampler_id, true, true,
};
auto texture_itr = find_if(begin(caller.arguments), end(caller.arguments),
[texture_id](const SPIRFunction::Parameter &p) { return p.id == texture_id; });
[image_id](const SPIRFunction::Parameter &p) { return p.id == image_id; });
auto sampler_itr = find_if(begin(caller.arguments), end(caller.arguments),
[sampler_id](const SPIRFunction::Parameter &p) { return p.id == sampler_id; });
if (texture_itr != end(caller.arguments))
{
param.global_texture = false;
param.texture_id = texture_itr - begin(caller.arguments);
param.global_image = false;
param.image_id = texture_itr - begin(caller.arguments);
}
if (sampler_itr != end(caller.arguments))
@ -2427,13 +2427,13 @@ void Compiler::CombinedImageSamplerHandler::register_combined_image_sampler(SPIR
param.sampler_id = sampler_itr - begin(caller.arguments);
}
if (param.global_texture && param.global_sampler)
if (param.global_image && param.global_sampler)
return;
auto itr = find_if(begin(caller.combined_parameters), end(caller.combined_parameters),
[&param](const SPIRFunction::CombinedImageSamplerParameter &p) {
return param.texture_id == p.texture_id && param.sampler_id == p.sampler_id &&
param.global_texture == p.global_texture && param.global_sampler == p.global_sampler;
return param.image_id == p.image_id && param.sampler_id == p.sampler_id &&
param.global_image == p.global_image && param.global_sampler == p.global_sampler;
});
if (itr == end(caller.combined_parameters))
@ -2442,7 +2442,7 @@ void Compiler::CombinedImageSamplerHandler::register_combined_image_sampler(SPIR
auto type_id = id + 0;
auto ptr_type_id = id + 1;
auto combined_id = id + 2;
auto &base = compiler.expression_type(texture_id);
auto &base = compiler.expression_type(image_id);
auto &type = compiler.set<SPIRType>(type_id);
auto &ptr_type = compiler.set<SPIRType>(ptr_type_id);
@ -2467,7 +2467,7 @@ void Compiler::CombinedImageSamplerHandler::register_combined_image_sampler(SPIR
param.id = combined_id;
compiler.set_name(combined_id,
join("SPIRV_Cross_Combined", compiler.to_name(texture_id), compiler.to_name(sampler_id)));
join("SPIRV_Cross_Combined", compiler.to_name(image_id), compiler.to_name(sampler_id)));
caller.combined_parameters.push_back(param);
caller.shadow_arguments.push_back({ ptr_type_id, combined_id, 0u, 0u });
@ -2490,7 +2490,7 @@ bool Compiler::CombinedImageSamplerHandler::handle(Op opcode, const uint32_t *ar
bool separate_image = type.basetype == SPIRType::Image && type.image.sampled == 1;
bool separate_sampler = type.basetype == SPIRType::Sampler;
// If not separate texture or sampler, don't bother.
// If not separate image or sampler, don't bother.
if (!separate_image && !separate_sampler)
return true;

View File

@ -1898,15 +1898,15 @@ string CompilerGLSL::to_combined_image_sampler(uint32_t image_id, uint32_t samp_
if (image_itr != end(args) || sampler_itr != end(args))
{
// If any parameter originates from a parameter, we will find it in our argument list.
bool global_texture = image_itr == end(args);
bool global_image = image_itr == end(args);
bool global_sampler = sampler_itr == end(args);
uint32_t texture_id = global_texture ? image_id : (image_itr - begin(args));
uint32_t sampler_id = global_sampler ? samp_id : (sampler_itr - begin(args));
uint32_t iid = global_image ? image_id : (image_itr - begin(args));
uint32_t sid = global_sampler ? samp_id : (sampler_itr - begin(args));
auto &combined = current_function->combined_parameters;
auto itr = find_if(begin(combined), end(combined), [=](const SPIRFunction::CombinedImageSamplerParameter &p) {
return p.global_texture == global_texture && p.global_sampler == global_sampler &&
p.texture_id == texture_id && p.sampler_id == sampler_id;
return p.global_image == global_image && p.global_sampler == global_sampler && p.image_id == iid &&
p.sampler_id == sid;
});
if (itr != end(combined))
@ -3096,18 +3096,18 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction)
for (auto &combined : callee.combined_parameters)
{
uint32_t texture_id = combined.global_texture ? combined.texture_id : arg[combined.texture_id];
uint32_t image_id = combined.global_image ? combined.image_id : arg[combined.image_id];
uint32_t sampler_id = combined.global_sampler ? combined.sampler_id : arg[combined.sampler_id];
auto *tex = maybe_get_backing_variable(texture_id);
if (tex)
texture_id = tex->self;
auto *image = maybe_get_backing_variable(image_id);
if (image)
image_id = image->self;
auto *samp = maybe_get_backing_variable(sampler_id);
if (samp)
sampler_id = samp->self;
arglist.push_back(to_combined_image_sampler(texture_id, sampler_id));
arglist.push_back(to_combined_image_sampler(image_id, sampler_id));
}
funexpr += merge(arglist);
funexpr += ")";