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:
authorChip Davis <cdavis@codeweavers.com>2019-08-02 23:11:19 +0300
committerChip Davis <cdavis@codeweavers.com>2019-09-02 02:35:53 +0300
commit39dce88d3b10485be380c5437fb7ecddbeafcd62 (patch)
treeb8d9cb404da9326ac45fd923cefcb8fb245585c7 /spirv_common.hpp
parent9b845a478807ce2af079f5f9b0e21ddac02f9143 (diff)
MSL: Add support for sampler Y'CbCr conversion.
This change introduces functions and in one case, a class, to support the `VK_KHR_sampler_ycbcr_conversion` extension. Except in the case of GBGR8 and BGRG8 formats, for which Metal natively supports implicit chroma reconstruction, we're on our own here. We have to do everything ourselves. Much of the complexity comes from the need to support multiple planes, which must now be passed to functions that use the corresponding combined image-samplers. The rest is from the actual Y'CbCr conversion itself, which requires additional post-processing of the sample retrieved from the image. Passing sampled images to a function was a particular problem. To support this, I've added a new class which is emitted to MSL shaders that pass sampled images with Y'CbCr conversions attached around. It can handle sampled images with or without Y'CbCr conversion. This is an awful abomination that should not exist, but I'm worried that there's some shader out there which does this. This support requires Metal 2.0 to work properly, because it uses default-constructed texture objects, which were only added in MSL 2. I'm not even going to get into arrays of combined image-samplers--that's a whole other can of worms. They are deliberately unsupported in this change. I've taken the liberty of refactoring the support for texture swizzling while I'm at it. It's now treated as a post-processing step similar to Y'CbCr conversion. I'd like to think this is cleaner than having everything in `to_function_name()`/`to_function_args()`. It still looks really hairy, though. I did, however, get rid of the explicit type arguments to `spvGatherSwizzle()`/`spvGatherCompareSwizzle()`. Update the C API. In addition to supporting this new functionality, add some compiler options that I added in previous changes, but for which I neglected to update the C API.
Diffstat (limited to 'spirv_common.hpp')
-rw-r--r--spirv_common.hpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/spirv_common.hpp b/spirv_common.hpp
index 1641fdaa..090df8a5 100644
--- a/spirv_common.hpp
+++ b/spirv_common.hpp
@@ -1431,6 +1431,9 @@ enum ExtendedDecorations
// Used for decorations like resource indices for samplers when part of combined image samplers.
// A variable might need to hold two resource indices in this case.
SPIRVCrossDecorationResourceIndexSecondary,
+ // Used for resource indices for multiplanar images when part of combined image samplers.
+ SPIRVCrossDecorationResourceIndexTertiary,
+ SPIRVCrossDecorationResourceIndexQuaternary,
// Marks a buffer block for using explicit offsets (GLSL/HLSL).
SPIRVCrossDecorationExplicitOffset,
@@ -1439,6 +1442,12 @@ enum ExtendedDecorations
// In MSL, this is used to adjust the WorkgroupId and GlobalInvocationId variables.
SPIRVCrossDecorationBuiltInDispatchBase,
+ // Apply to a variable that is a function parameter; marks it as being a "dynamic"
+ // combined image-sampler. In MSL, this is used when a function parameter might hold
+ // either a regular combined image-sampler or one that has an attached sampler
+ // Y'CbCr conversion.
+ SPIRVCrossDecorationDynamicImageSampler,
+
SPIRVCrossDecorationCount
};