Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/KhronosGroup/SPIRV-Cross.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBill Hollings <bill.hollings@brenwill.com>2021-11-08 23:59:45 +0300
committerBill Hollings <bill.hollings@brenwill.com>2021-11-08 23:59:45 +0300
commitfd252b21ff291f5dee8d74f1702d5755af30a776 (patch)
tree6e7448868f1419d7e68494f2f4bdc6d93f034ec0 /spirv_msl.cpp
parent2e0fb3a7784011ebd3c25cd1252beca0819fd1de (diff)
Separate (partially) the tracking of depth images from depth compare ops.
SPIR-V allows an image to be marked as a depth image, but with a non-depth format. Such images should be read or sampled as vectors instead of scalars, except when they are subject to compare operations. Don't mark an OpSampledImage as using a compare operation just because the image contains a depth marker. Instead, require that a compare operation is actually used on that image. Compiler::image_is_comparison() was really testing whether an image is a depth image, since it incorporates the depth marker. Rename that function to is_depth_image(), to clarify what it is really testing. In Compiler::is_depth_image(), do not treat an image as a depth image if it has been explicitly marked with a color format, unless the image is subject to compare operations. In CompilerMSL::to_function_name(), test for compare operations specifically, rather than assuming them from the depth-image marker. CompilerGLSL and CompilerMSL still contain a number of internal tests that use is_depth_image() both for testing for a depth image, and for testing whether compare operations are being used. I've left these as they are for now, but these should be cleaned up at some point. Add unit tests for fetch/sample depth images with color formats and no compare ops.
Diffstat (limited to 'spirv_msl.cpp')
-rw-r--r--spirv_msl.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/spirv_msl.cpp b/spirv_msl.cpp
index 3f53ebd5..b08bb86f 100644
--- a/spirv_msl.cpp
+++ b/spirv_msl.cpp
@@ -9393,8 +9393,6 @@ static bool needs_chroma_reconstruction(const MSLConstexprSampler *constexpr_sam
string CompilerMSL::to_function_name(const TextureFunctionNameArguments &args)
{
VariableID img = args.base.img;
- auto &imgtype = *args.base.imgtype;
-
const MSLConstexprSampler *constexpr_sampler = nullptr;
bool is_dynamic_img_sampler = false;
if (auto *var = maybe_get_backing_variable(img))
@@ -9408,8 +9406,9 @@ string CompilerMSL::to_function_name(const TextureFunctionNameArguments &args)
if (msl_options.swizzle_texture_samples && args.base.is_gather && !is_dynamic_img_sampler &&
(!constexpr_sampler || !constexpr_sampler->ycbcr_conversion_enable))
{
- add_spv_func_and_recompile(imgtype.image.depth ? SPVFuncImplGatherCompareSwizzle : SPVFuncImplGatherSwizzle);
- return imgtype.image.depth ? "spvGatherCompareSwizzle" : "spvGatherSwizzle";
+ bool is_compare = comparison_ids.count(img);
+ add_spv_func_and_recompile(is_compare ? SPVFuncImplGatherCompareSwizzle : SPVFuncImplGatherSwizzle);
+ return is_compare ? "spvGatherCompareSwizzle" : "spvGatherSwizzle";
}
auto *combined = maybe_get<SPIRCombinedImageSampler>(img);
@@ -10021,7 +10020,7 @@ string CompilerMSL::to_function_args(const TextureFunctionArguments &args, bool
image_var = var->self;
}
- if (image_var == 0 || !image_is_comparison(expression_type(image_var), image_var))
+ if (image_var == 0 || !is_depth_image(expression_type(image_var), image_var))
farg_str += ", " + to_component_argument(args.component);
}
}
@@ -13631,7 +13630,7 @@ string CompilerMSL::image_type_glsl(const SPIRType &type, uint32_t id)
// Bypass pointers because we need the real image struct
auto &img_type = get<SPIRType>(type.self).image;
- if (image_is_comparison(type, id))
+ if (is_depth_image(type, id))
{
switch (img_type.dim)
{