Implement subpassInputMS loading.

This commit is contained in:
Hans-Kristian Arntzen 2016-07-11 13:36:11 +02:00
Родитель 7af13b68d5
Коммит 3265e1fc3f
4 изменённых файлов: 71 добавлений и 4 удалений

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

@ -0,0 +1,14 @@
#version 310 es
precision mediump float;
precision highp int;
layout(binding = 0) uniform mediump sampler2DMS uSubpass0;
layout(binding = 1) uniform mediump sampler2DMS uSubpass1;
layout(location = 0) out vec4 FragColor;
void main()
{
FragColor = (texelFetch(uSubpass0, ivec2(gl_FragCoord.xy), 1) + texelFetch(uSubpass1, ivec2(gl_FragCoord.xy), 2));
}

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

@ -0,0 +1,14 @@
#version 310 es
precision mediump float;
precision highp int;
layout(input_attachment_index = 0, set = 0, binding = 0) uniform mediump subpassInputMS uSubpass0;
layout(input_attachment_index = 1, set = 0, binding = 1) uniform mediump subpassInputMS uSubpass1;
layout(location = 0) out vec4 FragColor;
void main()
{
FragColor = (subpassLoad(uSubpass0, 1) + subpassLoad(uSubpass1, 2));
}

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

@ -0,0 +1,11 @@
#version 310 es
precision mediump float;
layout(input_attachment_index = 0, set = 0, binding = 0) uniform mediump subpassInputMS uSubpass0;
layout(input_attachment_index = 1, set = 0, binding = 1) uniform mediump subpassInputMS uSubpass1;
layout(location = 0) out vec4 FragColor;
void main()
{
FragColor = subpassLoad(uSubpass0, 1) + subpassLoad(uSubpass1, 2);
}

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

@ -3560,6 +3560,9 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction)
if (var && var->remapped_variable) // Remapped input, just read as-is without any op-code
{
if (type.image.ms)
throw CompilerError("Trying to remap multisampled image to variable, this is not possible.");
auto itr =
find_if(begin(pls_inputs), end(pls_inputs), [var](const PlsRemap &pls) { return pls.id == var->self; });
@ -3585,12 +3588,37 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction)
if (options.vulkan_semantics)
{
// With Vulkan semantics, use the proper Vulkan GLSL construct.
imgexpr = join("subpassLoad(", to_expression(ops[2]), ")");
if (type.image.ms)
{
uint32_t operands = ops[4];
if (operands != ImageOperandsSampleMask || length != 6)
throw CompilerError(
"Multisampled image used in OpImageRead, but unexpected operand mask was used.");
uint32_t samples = ops[5];
imgexpr = join("subpassLoad(", to_expression(ops[2]), ", ", to_expression(samples), ")");
}
else
imgexpr = join("subpassLoad(", to_expression(ops[2]), ")");
}
else
{
// Implement subpass loads via texture barrier style sampling.
imgexpr = join("texelFetch(", to_expression(ops[2]), ", ivec2(gl_FragCoord.xy), 0)");
if (type.image.ms)
{
uint32_t operands = ops[4];
if (operands != ImageOperandsSampleMask || length != 6)
throw CompilerError(
"Multisampled image used in OpImageRead, but unexpected operand mask was used.");
uint32_t samples = ops[5];
imgexpr = join("texelFetch(", to_expression(ops[2]), ", ivec2(gl_FragCoord.xy), ",
to_expression(samples), ")");
}
else
{
// Implement subpass loads via texture barrier style sampling.
imgexpr = join("texelFetch(", to_expression(ops[2]), ", ivec2(gl_FragCoord.xy), 0)");
}
}
pure = true;
}
@ -3967,7 +3995,7 @@ string CompilerGLSL::image_type_glsl(const SPIRType &type)
}
if (type.basetype == SPIRType::Image && type.image.dim == DimSubpassData && options.vulkan_semantics)
return res + "subpassInput";
return res + "subpassInput" + (type.image.ms ? "MS" : "");
// If we're emulating subpassInput with samplers, force sampler2D
// so we don't have to specify format.