Merge pull request #521 from KhronosGroup/fix-516
Support dual-source blending on GLSL and MSL.
This commit is contained in:
Коммит
65be63fd04
|
@ -0,0 +1,19 @@
|
|||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
|
||||
using namespace metal;
|
||||
|
||||
struct main0_out
|
||||
{
|
||||
float4 FragColor0 [[color(0), index(0)]];
|
||||
float4 FragColor1 [[color(0), index(1)]];
|
||||
};
|
||||
|
||||
fragment main0_out main0()
|
||||
{
|
||||
main0_out out = {};
|
||||
out.FragColor0 = float4(1.0);
|
||||
out.FragColor1 = float4(2.0);
|
||||
return out;
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
#version 450
|
||||
|
||||
layout(location = 0, index = 0) out vec4 FragColor0;
|
||||
layout(location = 0, index = 1) out vec4 FragColor1;
|
||||
|
||||
void main()
|
||||
{
|
||||
FragColor0 = vec4(1.0);
|
||||
FragColor1 = vec4(2.0);
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
|
||||
using namespace metal;
|
||||
|
||||
struct main0_out
|
||||
{
|
||||
float4 FragColor0 [[color(0), index(0)]];
|
||||
float4 FragColor1 [[color(0), index(1)]];
|
||||
};
|
||||
|
||||
fragment main0_out main0()
|
||||
{
|
||||
main0_out out = {};
|
||||
out.FragColor0 = float4(1.0);
|
||||
out.FragColor1 = float4(2.0);
|
||||
return out;
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
#version 450
|
||||
|
||||
layout(location = 0, index = 0) out vec4 FragColor0;
|
||||
layout(location = 0, index = 1) out vec4 FragColor1;
|
||||
|
||||
void main()
|
||||
{
|
||||
FragColor0 = vec4(1.0);
|
||||
FragColor1 = vec4(2.0);
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
#version 450
|
||||
|
||||
layout(location = 0, index = 0) out vec4 FragColor0;
|
||||
layout(location = 0, index = 1) out vec4 FragColor1;
|
||||
|
||||
void main()
|
||||
{
|
||||
FragColor0 = vec4(1.0);
|
||||
FragColor1 = vec4(2.0);
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
#version 450
|
||||
|
||||
layout(location = 0, index = 0) out vec4 FragColor0;
|
||||
layout(location = 0, index = 1) out vec4 FragColor1;
|
||||
|
||||
void main()
|
||||
{
|
||||
FragColor0 = vec4(1.0);
|
||||
FragColor1 = vec4(2.0);
|
||||
}
|
|
@ -1195,6 +1195,7 @@ struct Meta
|
|||
uint32_t matrix_stride = 0;
|
||||
uint32_t input_attachment = 0;
|
||||
uint32_t spec_id = 0;
|
||||
uint32_t index = 0;
|
||||
bool builtin = false;
|
||||
};
|
||||
|
||||
|
|
|
@ -1074,6 +1074,10 @@ void Compiler::set_member_decoration(uint32_t id, uint32_t index, Decoration dec
|
|||
dec.matrix_stride = argument;
|
||||
break;
|
||||
|
||||
case DecorationIndex:
|
||||
dec.index = argument;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -1146,6 +1150,8 @@ uint32_t Compiler::get_member_decoration(uint32_t id, uint32_t index, Decoration
|
|||
return dec.offset;
|
||||
case DecorationSpecId:
|
||||
return dec.spec_id;
|
||||
case DecorationIndex:
|
||||
return dec.index;
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
|
@ -1249,6 +1255,10 @@ void Compiler::set_decoration(uint32_t id, Decoration decoration, uint32_t argum
|
|||
dec.spec_id = argument;
|
||||
break;
|
||||
|
||||
case DecorationIndex:
|
||||
dec.index = argument;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -1320,6 +1330,8 @@ uint32_t Compiler::get_decoration(uint32_t id, Decoration decoration) const
|
|||
return dec.array_stride;
|
||||
case DecorationMatrixStride:
|
||||
return dec.matrix_stride;
|
||||
case DecorationIndex:
|
||||
return dec.index;
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -1209,6 +1209,9 @@ string CompilerGLSL::layout_for_variable(const SPIRVariable &var)
|
|||
attr.push_back(join("location = ", dec.location));
|
||||
}
|
||||
|
||||
if (flags.get(DecorationIndex))
|
||||
attr.push_back(join("index = ", dec.index));
|
||||
|
||||
// set = 0 is the default. Do not emit set = decoration in regular GLSL output, but
|
||||
// we should preserve it in Vulkan GLSL mode.
|
||||
if (var.storage != StorageClassPushConstant)
|
||||
|
|
|
@ -645,6 +645,12 @@ uint32_t CompilerMSL::add_interface_block(StorageClass storage)
|
|||
mark_location_as_used_by_shader(locn, storage);
|
||||
}
|
||||
|
||||
if (get_decoration_bitset(p_var->self).get(DecorationIndex))
|
||||
{
|
||||
uint32_t index = get_decoration(p_var->self, DecorationIndex);
|
||||
set_member_decoration(ib_type_id, ib_mbr_idx, DecorationIndex, index);
|
||||
}
|
||||
|
||||
// Lower the internal array to flattened output when entry point returns.
|
||||
entry_func.fixup_statements.push_back(
|
||||
join(ib_var_ref, ".", mbr_name, " = ", to_name(p_var->self), "[", i, "];"));
|
||||
|
@ -674,6 +680,12 @@ uint32_t CompilerMSL::add_interface_block(StorageClass storage)
|
|||
mark_location_as_used_by_shader(locn, storage);
|
||||
}
|
||||
|
||||
if (get_decoration_bitset(p_var->self).get(DecorationIndex))
|
||||
{
|
||||
uint32_t index = get_decoration(p_var->self, DecorationIndex);
|
||||
set_member_decoration(ib_type_id, ib_mbr_idx, DecorationIndex, index);
|
||||
}
|
||||
|
||||
// Mark the member as builtin if needed
|
||||
if (is_builtin)
|
||||
{
|
||||
|
@ -2835,8 +2847,14 @@ string CompilerMSL::member_attribute_qualifier(const SPIRType &type, uint32_t in
|
|||
}
|
||||
}
|
||||
uint32_t locn = get_ordered_member_location(type.self, index);
|
||||
if (locn != k_unknown_location)
|
||||
return string(" [[color(") + convert_to_string(locn) + ")]]";
|
||||
if (locn != k_unknown_location && has_member_decoration(type.self, index, DecorationIndex))
|
||||
return join(" [[color(", locn, "), index(", get_member_decoration(type.self, index, DecorationIndex), ")]]");
|
||||
else if (locn != k_unknown_location)
|
||||
return join(" [[color(", locn, ")]]");
|
||||
else if (has_member_decoration(type.self, index, DecorationIndex))
|
||||
return join(" [[index(", get_member_decoration(type.self, index, DecorationIndex), ")]]");
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
// Compute function inputs
|
||||
|
|
Загрузка…
Ссылка в новой задаче