This commit is contained in:
Bill Hollings 2017-06-01 16:29:39 -04:00
Родитель ba245697f1
Коммит 6f3381a5d3
3 изменённых файлов: 14 добавлений и 7 удалений

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

@ -1469,6 +1469,10 @@ void Compiler::parse(const Instruction &instruction)
type.image.sampled = ops[6];
type.image.format = static_cast<ImageFormat>(ops[7]);
type.image.access = (length >= 9) ? static_cast<AccessQualifier>(ops[8]) : AccessQualifierMax;
if (type.image.sampled == 0)
SPIRV_CROSS_THROW("OpTypeImage Sampled parameter must not be zero.");
break;
}

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

@ -2893,11 +2893,6 @@ void CompilerGLSL::emit_texture_op(const Instruction &i)
auto &type = expression_type(img);
auto &imgtype = get<SPIRType>(type.self);
// Mark that this shader reads from this image
auto *p_var = maybe_get_backing_variable(img);
if (p_var)
unset_decoration(p_var->self, DecorationNonReadable);
uint32_t coord_components = 0;
switch (imgtype.image.dim)
{

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

@ -1179,10 +1179,18 @@ void CompilerMSL::emit_instruction(const Instruction &instruction)
// Images
// Reads == fetches in Metal
// Reads == Fetches in Metal
case OpImageRead:
{
// Mark that this shader reads from this image
uint32_t img_id = ops[2];
auto *p_var = maybe_get_backing_variable(img_id);
if (p_var)
unset_decoration(p_var->self, DecorationNonReadable);
emit_texture_op(instruction);
break;
}
case OpImageWrite:
{
@ -2490,7 +2498,7 @@ string CompilerMSL::image_type_glsl(const SPIRType &type, uint32_t id)
// For unsampled images, append the sample/read/write access qualifier.
// For kernel images, the access qualifier my be supplied directly by SPIR-V.
// Otherwise it may be set based on whether the image is read from or written to within the shader.
if (type.basetype == SPIRType::Image)
if (type.basetype == SPIRType::Image && type.image.sampled == 2)
{
switch (img_type.access)
{