Implement data packing intrinsics

* Fix how the HLSL writer determines how to use a RWByteAddressBuffer
* Fix how the HLSL writer decides the register space for a storage
  variable
* Fix inference of hlsl format in the tint executable
* Add support for data packing intrinsics
  * type determination
  * validation
  * writers
  * spirv reader

Bug: tint:340, tint:473, tint:474
Change-Id: I45dc8fd7c6f9abc7d30f617c7e3d713d7965b76e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/40342
Commit-Queue: Alan Baker <alanbaker@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
Alan Baker
2021-02-04 16:17:49 +00:00
committed by Commit Bot service account
parent fbd47c752e
commit c63e1c0791
16 changed files with 706 additions and 130 deletions

View File

@@ -124,6 +124,16 @@ const char* str(Intrinsic i) {
return "modf";
case Intrinsic::kNormalize:
return "normalize";
case Intrinsic::kPack4x8Snorm:
return "pack4x8snorm";
case Intrinsic::kPack4x8Unorm:
return "pack4x8unorm";
case Intrinsic::kPack2x16Snorm:
return "pack2x16snorm";
case Intrinsic::kPack2x16Unorm:
return "pack2x16unorm";
case Intrinsic::kPack2x16Float:
return "pack2x16float";
case Intrinsic::kPow:
return "pow";
case Intrinsic::kReflect:
@@ -215,6 +225,12 @@ bool IsImageQueryIntrinsic(Intrinsic i) {
i == Intrinsic::kTextureNumSamples;
}
bool IsDataPackingIntrinsic(Intrinsic i) {
return i == Intrinsic::kPack4x8Snorm || i == Intrinsic::kPack4x8Unorm ||
i == Intrinsic::kPack2x16Snorm || i == Intrinsic::kPack2x16Unorm ||
i == Intrinsic::kPack2x16Float;
}
} // namespace intrinsic
} // namespace semantic
} // namespace tint

View File

@@ -70,6 +70,11 @@ enum class Intrinsic {
kMix,
kModf,
kNormalize,
kPack4x8Snorm,
kPack4x8Unorm,
kPack2x16Snorm,
kPack2x16Unorm,
kPack2x16Float,
kPow,
kReflect,
kReverseBits,
@@ -133,6 +138,11 @@ bool IsTextureIntrinsic(Intrinsic i);
/// @returns true if the given `i` is a image query intrinsic
bool IsImageQueryIntrinsic(Intrinsic i);
/// Determines if the given `i` is a data packing intrinsic
/// @param i the intrinsic
/// @returns true if the given `i` is a data packing intrinsic
bool IsDataPackingIntrinsic(Intrinsic i);
/// @returns the name of the intrinsic function. The spelling, including case,
/// matches the name in the WGSL spec.
const char* str(Intrinsic i);