Add reflection support for separate textures and samplers.

This commit is contained in:
Hans-Kristian Arntzen 2016-09-10 13:05:35 +02:00
Родитель 32b463f740
Коммит e92020819e
3 изменённых файлов: 20 добавлений и 1 удалений

Просмотреть файл

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

Просмотреть файл

@ -583,10 +583,22 @@ ShaderResources Compiler::get_shader_resources(const unordered_set<uint32_t> *ac
res.push_constant_buffers.push_back({ var.self, var.basetype, type.self, meta[var.self].decoration.alias }); res.push_constant_buffers.push_back({ var.self, var.basetype, type.self, meta[var.self].decoration.alias });
} }
// Images // Images
else if (type.storage == StorageClassUniformConstant && type.basetype == SPIRType::Image) else if (type.storage == StorageClassUniformConstant && type.basetype == SPIRType::Image &&
type.image.sampled == 2)
{ {
res.storage_images.push_back({ var.self, var.basetype, type.self, meta[var.self].decoration.alias }); res.storage_images.push_back({ var.self, var.basetype, type.self, meta[var.self].decoration.alias });
} }
// Separate images
else if (type.storage == StorageClassUniformConstant && type.basetype == SPIRType::Image &&
type.image.sampled == 1)
{
res.separate_images.push_back({ var.self, var.basetype, type.self, meta[var.self].decoration.alias });
}
// Separate samplers
else if (type.storage == StorageClassUniformConstant && type.basetype == SPIRType::Sampler)
{
res.separate_samplers.push_back({ var.self, var.basetype, type.self, meta[var.self].decoration.alias });
}
// Textures // Textures
else if (type.storage == StorageClassUniformConstant && type.basetype == SPIRType::SampledImage) else if (type.storage == StorageClassUniformConstant && type.basetype == SPIRType::SampledImage)
{ {

Просмотреть файл

@ -73,6 +73,11 @@ struct ShaderResources
// There can only be one push constant block, // There can only be one push constant block,
// but keep the vector in case this restriction is lifted in the future. // but keep the vector in case this restriction is lifted in the future.
std::vector<Resource> push_constant_buffers; std::vector<Resource> push_constant_buffers;
// For Vulkan GLSL and HLSL source,
// these correspond to separate texture2D and samplers respectively.
std::vector<Resource> separate_images;
std::vector<Resource> separate_samplers;
}; };
struct BufferRange struct BufferRange