Updated spirv-cross.

This commit is contained in:
Бранимир Караџић 2019-10-26 08:03:21 -07:00
parent ace4142b94
commit 77ddea8ec1
3 changed files with 30 additions and 11 deletions

View File

@ -61,7 +61,7 @@ void CFG::build_immediate_dominators()
if (immediate_dominators[block])
{
assert(immediate_dominators[edge]);
immediate_dominators[block] = find_common_dominator(block, edge);
immediate_dominators[block] = find_common_dominator(immediate_dominators[block], edge);
}
else
immediate_dominators[block] = edge;

View File

@ -6596,6 +6596,14 @@ string CompilerMSL::to_function_args(VariableID img, const SPIRType &imgtype, bo
else if (sampling_type_needs_f32_conversion(coord_type))
tex_coords = convert_to_f32(tex_coords, 1);
if (msl_options.texture_1D_as_2D)
{
if (is_fetch)
tex_coords = "uint2(" + tex_coords + ", 0)";
else
tex_coords = "float2(" + tex_coords + ", 0.5)";
}
alt_coord_component = 1;
break;
@ -6787,14 +6795,14 @@ string CompilerMSL::to_function_args(VariableID img, const SPIRType &imgtype, bo
// LOD Options
// Metal does not support LOD for 1D textures.
if (bias && imgtype.image.dim != Dim1D)
if (bias && (imgtype.image.dim != Dim1D || msl_options.texture_1D_as_2D))
{
forward = forward && should_forward(bias);
farg_str += ", bias(" + to_expression(bias) + ")";
}
// Metal does not support LOD for 1D textures.
if (lod && imgtype.image.dim != Dim1D)
if (lod && (imgtype.image.dim != Dim1D || msl_options.texture_1D_as_2D))
{
forward = forward && should_forward(lod);
if (is_fetch)
@ -6806,8 +6814,8 @@ string CompilerMSL::to_function_args(VariableID img, const SPIRType &imgtype, bo
farg_str += ", level(" + to_expression(lod) + ")";
}
}
else if (is_fetch && !lod && imgtype.image.dim != Dim1D && imgtype.image.dim != DimBuffer && !imgtype.image.ms &&
imgtype.image.sampled != 2)
else if (is_fetch && !lod && (imgtype.image.dim != Dim1D || msl_options.texture_1D_as_2D) &&
imgtype.image.dim != DimBuffer && !imgtype.image.ms && imgtype.image.sampled != 2)
{
// Lod argument is optional in OpImageFetch, but we require a LOD value, pick 0 as the default.
// Check for sampled type as well, because is_fetch is also used for OpImageRead in MSL.
@ -6815,7 +6823,7 @@ string CompilerMSL::to_function_args(VariableID img, const SPIRType &imgtype, bo
}
// Metal does not support LOD for 1D textures.
if ((grad_x || grad_y) && imgtype.image.dim != Dim1D)
if ((grad_x || grad_y) && (imgtype.image.dim != Dim1D || msl_options.texture_1D_as_2D))
{
forward = forward && should_forward(grad_x);
forward = forward && should_forward(grad_y);
@ -9547,8 +9555,13 @@ string CompilerMSL::image_type_glsl(const SPIRType &type, uint32_t id)
switch (img_type.dim)
{
case Dim1D:
img_type_name += "depth1d_unsupported_by_metal";
break;
if (!msl_options.texture_1D_as_2D)
{
// Use a native Metal 1D texture
img_type_name += "depth1d_unsupported_by_metal";
break;
}
// else fall through and use 2D
case Dim2D:
if (img_type.ms && img_type.arrayed)
{
@ -9578,9 +9591,6 @@ string CompilerMSL::image_type_glsl(const SPIRType &type, uint32_t id)
{
switch (img_type.dim)
{
case Dim1D:
img_type_name += (img_type.arrayed ? "texture1d_array" : "texture1d");
break;
case DimBuffer:
if (img_type.ms || img_type.arrayed)
SPIRV_CROSS_THROW("Cannot use texel buffers with multisampling or array layers.");
@ -9594,6 +9604,14 @@ string CompilerMSL::image_type_glsl(const SPIRType &type, uint32_t id)
else
img_type_name += "texture2d";
break;
case Dim1D:
if (!msl_options.texture_1D_as_2D)
{
// Use a native Metal 1D texture
img_type_name += (img_type.arrayed ? "texture1d_array" : "texture1d");
break;
}
// else fall through and use 2D
case Dim2D:
case DimSubpassData:
if (img_type.ms && img_type.arrayed)

View File

@ -274,6 +274,7 @@ public:
bool multiview = false;
bool view_index_from_device_index = false;
bool dispatch_base = false;
bool texture_1D_as_2D = false;
// Enable use of MSL 2.0 indirect argument buffers.
// MSL 2.0 must also be enabled.