spirv-reader: use spirv.hpp11
In preparation for SPIRV-Tools change where its internals use the C++11 headers. This patch works with SPIRV-Tools using the old C header and using the C++11 header. This patch includes some complex machinery inside "three_sided_patch" namespaces that can be removed after third_party/vulkan-deps/spirv-tools has fully transitioned into using the C++11 headers. Change-Id: I36f358fe3edcc5e613625708017fb8d7919c40c6 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108780 Reviewed-by: Alan Baker <alanbaker@google.com> Commit-Queue: David Neto <dneto@google.com> Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
parent
82f6475faf
commit
eb949c87ee
|
@ -20,13 +20,13 @@ EnumConverter::EnumConverter(const FailStream& fs) : fail_stream_(fs) {}
|
|||
|
||||
EnumConverter::~EnumConverter() = default;
|
||||
|
||||
ast::PipelineStage EnumConverter::ToPipelineStage(SpvExecutionModel model) {
|
||||
ast::PipelineStage EnumConverter::ToPipelineStage(spv::ExecutionModel model) {
|
||||
switch (model) {
|
||||
case SpvExecutionModelVertex:
|
||||
case spv::ExecutionModel::Vertex:
|
||||
return ast::PipelineStage::kVertex;
|
||||
case SpvExecutionModelFragment:
|
||||
case spv::ExecutionModel::Fragment:
|
||||
return ast::PipelineStage::kFragment;
|
||||
case SpvExecutionModelGLCompute:
|
||||
case spv::ExecutionModel::GLCompute:
|
||||
return ast::PipelineStage::kCompute;
|
||||
default:
|
||||
break;
|
||||
|
@ -36,23 +36,23 @@ ast::PipelineStage EnumConverter::ToPipelineStage(SpvExecutionModel model) {
|
|||
return ast::PipelineStage::kNone;
|
||||
}
|
||||
|
||||
ast::AddressSpace EnumConverter::ToAddressSpace(const SpvStorageClass sc) {
|
||||
ast::AddressSpace EnumConverter::ToAddressSpace(const spv::StorageClass sc) {
|
||||
switch (sc) {
|
||||
case SpvStorageClassInput:
|
||||
case spv::StorageClass::Input:
|
||||
return ast::AddressSpace::kIn;
|
||||
case SpvStorageClassOutput:
|
||||
case spv::StorageClass::Output:
|
||||
return ast::AddressSpace::kOut;
|
||||
case SpvStorageClassUniform:
|
||||
case spv::StorageClass::Uniform:
|
||||
return ast::AddressSpace::kUniform;
|
||||
case SpvStorageClassWorkgroup:
|
||||
case spv::StorageClass::Workgroup:
|
||||
return ast::AddressSpace::kWorkgroup;
|
||||
case SpvStorageClassUniformConstant:
|
||||
case spv::StorageClass::UniformConstant:
|
||||
return ast::AddressSpace::kNone;
|
||||
case SpvStorageClassStorageBuffer:
|
||||
case spv::StorageClass::StorageBuffer:
|
||||
return ast::AddressSpace::kStorage;
|
||||
case SpvStorageClassPrivate:
|
||||
case spv::StorageClass::Private:
|
||||
return ast::AddressSpace::kPrivate;
|
||||
case SpvStorageClassFunction:
|
||||
case spv::StorageClass::Function:
|
||||
return ast::AddressSpace::kFunction;
|
||||
default:
|
||||
break;
|
||||
|
@ -62,31 +62,31 @@ ast::AddressSpace EnumConverter::ToAddressSpace(const SpvStorageClass sc) {
|
|||
return ast::AddressSpace::kUndefined;
|
||||
}
|
||||
|
||||
ast::BuiltinValue EnumConverter::ToBuiltin(SpvBuiltIn b) {
|
||||
ast::BuiltinValue EnumConverter::ToBuiltin(spv::BuiltIn b) {
|
||||
switch (b) {
|
||||
case SpvBuiltInPosition:
|
||||
case spv::BuiltIn::Position:
|
||||
return ast::BuiltinValue::kPosition;
|
||||
case SpvBuiltInVertexIndex:
|
||||
case spv::BuiltIn::VertexIndex:
|
||||
return ast::BuiltinValue::kVertexIndex;
|
||||
case SpvBuiltInInstanceIndex:
|
||||
case spv::BuiltIn::InstanceIndex:
|
||||
return ast::BuiltinValue::kInstanceIndex;
|
||||
case SpvBuiltInFrontFacing:
|
||||
case spv::BuiltIn::FrontFacing:
|
||||
return ast::BuiltinValue::kFrontFacing;
|
||||
case SpvBuiltInFragCoord:
|
||||
case spv::BuiltIn::FragCoord:
|
||||
return ast::BuiltinValue::kPosition;
|
||||
case SpvBuiltInFragDepth:
|
||||
case spv::BuiltIn::FragDepth:
|
||||
return ast::BuiltinValue::kFragDepth;
|
||||
case SpvBuiltInLocalInvocationId:
|
||||
case spv::BuiltIn::LocalInvocationId:
|
||||
return ast::BuiltinValue::kLocalInvocationId;
|
||||
case SpvBuiltInLocalInvocationIndex:
|
||||
case spv::BuiltIn::LocalInvocationIndex:
|
||||
return ast::BuiltinValue::kLocalInvocationIndex;
|
||||
case SpvBuiltInGlobalInvocationId:
|
||||
case spv::BuiltIn::GlobalInvocationId:
|
||||
return ast::BuiltinValue::kGlobalInvocationId;
|
||||
case SpvBuiltInWorkgroupId:
|
||||
case spv::BuiltIn::WorkgroupId:
|
||||
return ast::BuiltinValue::kWorkgroupId;
|
||||
case SpvBuiltInSampleId:
|
||||
case spv::BuiltIn::SampleId:
|
||||
return ast::BuiltinValue::kSampleIndex;
|
||||
case SpvBuiltInSampleMask:
|
||||
case spv::BuiltIn::SampleMask:
|
||||
return ast::BuiltinValue::kSampleMask;
|
||||
default:
|
||||
break;
|
||||
|
@ -96,12 +96,12 @@ ast::BuiltinValue EnumConverter::ToBuiltin(SpvBuiltIn b) {
|
|||
return ast::BuiltinValue::kUndefined;
|
||||
}
|
||||
|
||||
ast::TextureDimension EnumConverter::ToDim(SpvDim dim, bool arrayed) {
|
||||
ast::TextureDimension EnumConverter::ToDim(spv::Dim dim, bool arrayed) {
|
||||
if (arrayed) {
|
||||
switch (dim) {
|
||||
case SpvDim2D:
|
||||
case spv::Dim::Dim2D:
|
||||
return ast::TextureDimension::k2dArray;
|
||||
case SpvDimCube:
|
||||
case spv::Dim::Cube:
|
||||
return ast::TextureDimension::kCubeArray;
|
||||
default:
|
||||
break;
|
||||
|
@ -111,13 +111,13 @@ ast::TextureDimension EnumConverter::ToDim(SpvDim dim, bool arrayed) {
|
|||
}
|
||||
// Assume non-arrayed
|
||||
switch (dim) {
|
||||
case SpvDim1D:
|
||||
case spv::Dim::Dim1D:
|
||||
return ast::TextureDimension::k1d;
|
||||
case SpvDim2D:
|
||||
case spv::Dim::Dim2D:
|
||||
return ast::TextureDimension::k2d;
|
||||
case SpvDim3D:
|
||||
case spv::Dim::Dim3D:
|
||||
return ast::TextureDimension::k3d;
|
||||
case SpvDimCube:
|
||||
case spv::Dim::Cube:
|
||||
return ast::TextureDimension::kCube;
|
||||
default:
|
||||
break;
|
||||
|
@ -126,47 +126,47 @@ ast::TextureDimension EnumConverter::ToDim(SpvDim dim, bool arrayed) {
|
|||
return ast::TextureDimension::kNone;
|
||||
}
|
||||
|
||||
ast::TexelFormat EnumConverter::ToTexelFormat(SpvImageFormat fmt) {
|
||||
ast::TexelFormat EnumConverter::ToTexelFormat(spv::ImageFormat fmt) {
|
||||
switch (fmt) {
|
||||
case SpvImageFormatUnknown:
|
||||
case spv::ImageFormat::Unknown:
|
||||
return ast::TexelFormat::kUndefined;
|
||||
|
||||
// 8 bit channels
|
||||
case SpvImageFormatRgba8:
|
||||
case spv::ImageFormat::Rgba8:
|
||||
return ast::TexelFormat::kRgba8Unorm;
|
||||
case SpvImageFormatRgba8Snorm:
|
||||
case spv::ImageFormat::Rgba8Snorm:
|
||||
return ast::TexelFormat::kRgba8Snorm;
|
||||
case SpvImageFormatRgba8ui:
|
||||
case spv::ImageFormat::Rgba8ui:
|
||||
return ast::TexelFormat::kRgba8Uint;
|
||||
case SpvImageFormatRgba8i:
|
||||
case spv::ImageFormat::Rgba8i:
|
||||
return ast::TexelFormat::kRgba8Sint;
|
||||
|
||||
// 16 bit channels
|
||||
case SpvImageFormatRgba16ui:
|
||||
case spv::ImageFormat::Rgba16ui:
|
||||
return ast::TexelFormat::kRgba16Uint;
|
||||
case SpvImageFormatRgba16i:
|
||||
case spv::ImageFormat::Rgba16i:
|
||||
return ast::TexelFormat::kRgba16Sint;
|
||||
case SpvImageFormatRgba16f:
|
||||
case spv::ImageFormat::Rgba16f:
|
||||
return ast::TexelFormat::kRgba16Float;
|
||||
|
||||
// 32 bit channels
|
||||
case SpvImageFormatR32ui:
|
||||
case spv::ImageFormat::R32ui:
|
||||
return ast::TexelFormat::kR32Uint;
|
||||
case SpvImageFormatR32i:
|
||||
case spv::ImageFormat::R32i:
|
||||
return ast::TexelFormat::kR32Sint;
|
||||
case SpvImageFormatR32f:
|
||||
case spv::ImageFormat::R32f:
|
||||
return ast::TexelFormat::kR32Float;
|
||||
case SpvImageFormatRg32ui:
|
||||
case spv::ImageFormat::Rg32ui:
|
||||
return ast::TexelFormat::kRg32Uint;
|
||||
case SpvImageFormatRg32i:
|
||||
case spv::ImageFormat::Rg32i:
|
||||
return ast::TexelFormat::kRg32Sint;
|
||||
case SpvImageFormatRg32f:
|
||||
case spv::ImageFormat::Rg32f:
|
||||
return ast::TexelFormat::kRg32Float;
|
||||
case SpvImageFormatRgba32ui:
|
||||
case spv::ImageFormat::Rgba32ui:
|
||||
return ast::TexelFormat::kRgba32Uint;
|
||||
case SpvImageFormatRgba32i:
|
||||
case spv::ImageFormat::Rgba32i:
|
||||
return ast::TexelFormat::kRgba32Sint;
|
||||
case SpvImageFormatRgba32f:
|
||||
case spv::ImageFormat::Rgba32f:
|
||||
return ast::TexelFormat::kRgba32Float;
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#define SRC_TINT_READER_SPIRV_ENUM_CONVERTER_H_
|
||||
|
||||
#include "spirv/unified1/spirv.h"
|
||||
#include "spirv/unified1/spirv.hpp11"
|
||||
#include "src/tint/ast/address_space.h"
|
||||
#include "src/tint/ast/builtin_value.h"
|
||||
#include "src/tint/ast/pipeline_stage.h"
|
||||
|
@ -37,32 +38,49 @@ class EnumConverter {
|
|||
/// On failure, logs an error and returns kNone
|
||||
/// @param model the SPIR-V entry point execution model
|
||||
/// @returns a Tint AST pipeline stage
|
||||
ast::PipelineStage ToPipelineStage(SpvExecutionModel model);
|
||||
ast::PipelineStage ToPipelineStage(spv::ExecutionModel model);
|
||||
|
||||
/// Converts a SPIR-V storage class to a Tint address space.
|
||||
/// On failure, logs an error and returns kNone
|
||||
/// @param sc the SPIR-V storage class
|
||||
/// @returns a Tint AST address space
|
||||
ast::AddressSpace ToAddressSpace(const SpvStorageClass sc);
|
||||
ast::AddressSpace ToAddressSpace(const spv::StorageClass sc);
|
||||
|
||||
/// Converts a SPIR-V Builtin value a Tint Builtin.
|
||||
/// On failure, logs an error and returns kNone
|
||||
/// @param b the SPIR-V builtin
|
||||
/// @returns a Tint AST builtin
|
||||
ast::BuiltinValue ToBuiltin(SpvBuiltIn b);
|
||||
ast::BuiltinValue ToBuiltin(spv::BuiltIn b);
|
||||
|
||||
/// Converts a possibly arrayed SPIR-V Dim to a Tint texture dimension.
|
||||
/// On failure, logs an error and returns kNone
|
||||
/// @param dim the SPIR-V Dim value
|
||||
/// @param arrayed true if the texture is arrayed
|
||||
/// @returns a Tint AST texture dimension
|
||||
ast::TextureDimension ToDim(SpvDim dim, bool arrayed);
|
||||
ast::TextureDimension ToDim(spv::Dim dim, bool arrayed);
|
||||
|
||||
/// Converts a possibly arrayed SPIR-V Dim to a Tint texture dimension.
|
||||
/// On failure, logs an error and returns kNone
|
||||
/// @param dim the SPIR-V Dim value
|
||||
/// @param arrayed true if the texture is arrayed
|
||||
/// @returns a Tint AST texture dimension
|
||||
ast::TextureDimension ToDim(SpvDim dim, bool arrayed) {
|
||||
return ToDim(static_cast<spv::Dim>(dim), arrayed);
|
||||
}
|
||||
|
||||
/// Converts a SPIR-V Image Format to a TexelFormat
|
||||
/// On failure, logs an error and returns kNone
|
||||
/// @param fmt the SPIR-V format
|
||||
/// @returns a Tint AST format
|
||||
ast::TexelFormat ToTexelFormat(SpvImageFormat fmt);
|
||||
ast::TexelFormat ToTexelFormat(spv::ImageFormat fmt);
|
||||
|
||||
/// Converts a SPIR-V Image Format to a TexelFormat
|
||||
/// On failure, logs an error and returns kNone
|
||||
/// @param fmt the SPIR-V format
|
||||
/// @returns a Tint AST format
|
||||
ast::TexelFormat ToTexelFormat(SpvImageFormat fmt) {
|
||||
return ToTexelFormat(static_cast<spv::ImageFormat>(fmt));
|
||||
}
|
||||
|
||||
private:
|
||||
/// Registers a failure and returns a stream for log diagnostics.
|
||||
|
|
|
@ -24,12 +24,12 @@ namespace {
|
|||
// Pipeline stage
|
||||
|
||||
struct PipelineStageCase {
|
||||
SpvExecutionModel model;
|
||||
spv::ExecutionModel model;
|
||||
bool expect_success;
|
||||
ast::PipelineStage expected;
|
||||
};
|
||||
inline std::ostream& operator<<(std::ostream& out, PipelineStageCase psc) {
|
||||
out << "PipelineStageCase{ SpvExecutionModel:" << int(psc.model)
|
||||
out << "PipelineStageCase{ spv::ExecutionModel:::" << int(psc.model)
|
||||
<< " expect_success?:" << int(psc.expect_success) << " expected:" << int(psc.expected)
|
||||
<< "}";
|
||||
return out;
|
||||
|
@ -65,29 +65,29 @@ TEST_P(SpvPipelineStageTest, Samples) {
|
|||
|
||||
INSTANTIATE_TEST_SUITE_P(EnumConverterGood,
|
||||
SpvPipelineStageTest,
|
||||
testing::Values(PipelineStageCase{SpvExecutionModelVertex, true,
|
||||
testing::Values(PipelineStageCase{spv::ExecutionModel::Vertex, true,
|
||||
ast::PipelineStage::kVertex},
|
||||
PipelineStageCase{SpvExecutionModelFragment, true,
|
||||
PipelineStageCase{spv::ExecutionModel::Fragment, true,
|
||||
ast::PipelineStage::kFragment},
|
||||
PipelineStageCase{SpvExecutionModelGLCompute, true,
|
||||
PipelineStageCase{spv::ExecutionModel::GLCompute, true,
|
||||
ast::PipelineStage::kCompute}));
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(EnumConverterBad,
|
||||
SpvPipelineStageTest,
|
||||
testing::Values(PipelineStageCase{static_cast<SpvExecutionModel>(9999),
|
||||
testing::Values(PipelineStageCase{static_cast<spv::ExecutionModel>(9999),
|
||||
false, ast::PipelineStage::kNone},
|
||||
PipelineStageCase{SpvExecutionModelTessellationControl,
|
||||
PipelineStageCase{spv::ExecutionModel::TessellationControl,
|
||||
false, ast::PipelineStage::kNone}));
|
||||
|
||||
// Storage class
|
||||
|
||||
struct StorageClassCase {
|
||||
SpvStorageClass sc;
|
||||
spv::StorageClass sc;
|
||||
bool expect_success;
|
||||
ast::AddressSpace expected;
|
||||
};
|
||||
inline std::ostream& operator<<(std::ostream& out, StorageClassCase scc) {
|
||||
out << "StorageClassCase{ SpvStorageClass:" << int(scc.sc)
|
||||
out << "StorageClassCase{ spv::StorageClass:::" << int(scc.sc)
|
||||
<< " expect_success?:" << int(scc.expect_success) << " expected:" << int(scc.expected)
|
||||
<< "}";
|
||||
return out;
|
||||
|
@ -125,29 +125,29 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
EnumConverterGood,
|
||||
SpvStorageClassTest,
|
||||
testing::Values(
|
||||
StorageClassCase{SpvStorageClassInput, true, ast::AddressSpace::kIn},
|
||||
StorageClassCase{SpvStorageClassOutput, true, ast::AddressSpace::kOut},
|
||||
StorageClassCase{SpvStorageClassUniform, true, ast::AddressSpace::kUniform},
|
||||
StorageClassCase{SpvStorageClassWorkgroup, true, ast::AddressSpace::kWorkgroup},
|
||||
StorageClassCase{SpvStorageClassUniformConstant, true, ast::AddressSpace::kNone},
|
||||
StorageClassCase{SpvStorageClassStorageBuffer, true, ast::AddressSpace::kStorage},
|
||||
StorageClassCase{SpvStorageClassPrivate, true, ast::AddressSpace::kPrivate},
|
||||
StorageClassCase{SpvStorageClassFunction, true, ast::AddressSpace::kFunction}));
|
||||
StorageClassCase{spv::StorageClass::Input, true, ast::AddressSpace::kIn},
|
||||
StorageClassCase{spv::StorageClass::Output, true, ast::AddressSpace::kOut},
|
||||
StorageClassCase{spv::StorageClass::Uniform, true, ast::AddressSpace::kUniform},
|
||||
StorageClassCase{spv::StorageClass::Workgroup, true, ast::AddressSpace::kWorkgroup},
|
||||
StorageClassCase{spv::StorageClass::UniformConstant, true, ast::AddressSpace::kNone},
|
||||
StorageClassCase{spv::StorageClass::StorageBuffer, true, ast::AddressSpace::kStorage},
|
||||
StorageClassCase{spv::StorageClass::Private, true, ast::AddressSpace::kPrivate},
|
||||
StorageClassCase{spv::StorageClass::Function, true, ast::AddressSpace::kFunction}));
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(EnumConverterBad,
|
||||
SpvStorageClassTest,
|
||||
testing::Values(StorageClassCase{static_cast<SpvStorageClass>(9999), false,
|
||||
ast::AddressSpace::kUndefined}));
|
||||
testing::Values(StorageClassCase{static_cast<spv::StorageClass>(9999),
|
||||
false, ast::AddressSpace::kUndefined}));
|
||||
|
||||
// Builtin
|
||||
|
||||
struct BuiltinCase {
|
||||
SpvBuiltIn builtin;
|
||||
spv::BuiltIn builtin;
|
||||
bool expect_success;
|
||||
ast::BuiltinValue expected;
|
||||
};
|
||||
inline std::ostream& operator<<(std::ostream& out, BuiltinCase bc) {
|
||||
out << "BuiltinCase{ SpvBuiltIn:" << int(bc.builtin)
|
||||
out << "BuiltinCase{ spv::BuiltIn::" << int(bc.builtin)
|
||||
<< " expect_success?:" << int(bc.expect_success) << " expected:" << int(bc.expected) << "}";
|
||||
return out;
|
||||
}
|
||||
|
@ -184,43 +184,44 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
EnumConverterGood_Input,
|
||||
SpvBuiltinTest,
|
||||
testing::Values(
|
||||
BuiltinCase{SpvBuiltInPosition, true, ast::BuiltinValue::kPosition},
|
||||
BuiltinCase{SpvBuiltInInstanceIndex, true, ast::BuiltinValue::kInstanceIndex},
|
||||
BuiltinCase{SpvBuiltInFrontFacing, true, ast::BuiltinValue::kFrontFacing},
|
||||
BuiltinCase{SpvBuiltInFragCoord, true, ast::BuiltinValue::kPosition},
|
||||
BuiltinCase{SpvBuiltInLocalInvocationId, true, ast::BuiltinValue::kLocalInvocationId},
|
||||
BuiltinCase{SpvBuiltInLocalInvocationIndex, true, ast::BuiltinValue::kLocalInvocationIndex},
|
||||
BuiltinCase{SpvBuiltInGlobalInvocationId, true, ast::BuiltinValue::kGlobalInvocationId},
|
||||
BuiltinCase{SpvBuiltInWorkgroupId, true, ast::BuiltinValue::kWorkgroupId},
|
||||
BuiltinCase{SpvBuiltInSampleId, true, ast::BuiltinValue::kSampleIndex},
|
||||
BuiltinCase{SpvBuiltInSampleMask, true, ast::BuiltinValue::kSampleMask}));
|
||||
BuiltinCase{spv::BuiltIn::Position, true, ast::BuiltinValue::kPosition},
|
||||
BuiltinCase{spv::BuiltIn::InstanceIndex, true, ast::BuiltinValue::kInstanceIndex},
|
||||
BuiltinCase{spv::BuiltIn::FrontFacing, true, ast::BuiltinValue::kFrontFacing},
|
||||
BuiltinCase{spv::BuiltIn::FragCoord, true, ast::BuiltinValue::kPosition},
|
||||
BuiltinCase{spv::BuiltIn::LocalInvocationId, true, ast::BuiltinValue::kLocalInvocationId},
|
||||
BuiltinCase{spv::BuiltIn::LocalInvocationIndex, true,
|
||||
ast::BuiltinValue::kLocalInvocationIndex},
|
||||
BuiltinCase{spv::BuiltIn::GlobalInvocationId, true, ast::BuiltinValue::kGlobalInvocationId},
|
||||
BuiltinCase{spv::BuiltIn::WorkgroupId, true, ast::BuiltinValue::kWorkgroupId},
|
||||
BuiltinCase{spv::BuiltIn::SampleId, true, ast::BuiltinValue::kSampleIndex},
|
||||
BuiltinCase{spv::BuiltIn::SampleMask, true, ast::BuiltinValue::kSampleMask}));
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
EnumConverterGood_Output,
|
||||
SpvBuiltinTest,
|
||||
testing::Values(BuiltinCase{SpvBuiltInPosition, true, ast::BuiltinValue::kPosition},
|
||||
BuiltinCase{SpvBuiltInFragDepth, true, ast::BuiltinValue::kFragDepth},
|
||||
BuiltinCase{SpvBuiltInSampleMask, true, ast::BuiltinValue::kSampleMask}));
|
||||
testing::Values(BuiltinCase{spv::BuiltIn::Position, true, ast::BuiltinValue::kPosition},
|
||||
BuiltinCase{spv::BuiltIn::FragDepth, true, ast::BuiltinValue::kFragDepth},
|
||||
BuiltinCase{spv::BuiltIn::SampleMask, true, ast::BuiltinValue::kSampleMask}));
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(EnumConverterBad,
|
||||
SpvBuiltinTest,
|
||||
testing::Values(BuiltinCase{static_cast<SpvBuiltIn>(9999), false,
|
||||
testing::Values(BuiltinCase{static_cast<spv::BuiltIn>(9999), false,
|
||||
ast::BuiltinValue::kUndefined},
|
||||
BuiltinCase{static_cast<SpvBuiltIn>(9999), false,
|
||||
BuiltinCase{static_cast<spv::BuiltIn>(9999), false,
|
||||
ast::BuiltinValue::kUndefined},
|
||||
BuiltinCase{SpvBuiltInNumWorkgroups, false,
|
||||
BuiltinCase{spv::BuiltIn::NumWorkgroups, false,
|
||||
ast::BuiltinValue::kUndefined}));
|
||||
|
||||
// Dim
|
||||
|
||||
struct DimCase {
|
||||
SpvDim dim;
|
||||
spv::Dim dim;
|
||||
bool arrayed;
|
||||
bool expect_success;
|
||||
ast::TextureDimension expected;
|
||||
};
|
||||
inline std::ostream& operator<<(std::ostream& out, DimCase dc) {
|
||||
out << "DimCase{ SpvDim:" << int(dc.dim) << " arrayed?:" << int(dc.arrayed)
|
||||
out << "DimCase{ spv::Dim:::" << int(dc.dim) << " arrayed?:" << int(dc.arrayed)
|
||||
<< " expect_success?:" << int(dc.expect_success) << " expected:" << int(dc.expected) << "}";
|
||||
return out;
|
||||
}
|
||||
|
@ -256,40 +257,41 @@ INSTANTIATE_TEST_SUITE_P(EnumConverterGood,
|
|||
SpvDimTest,
|
||||
testing::Values(
|
||||
// Non-arrayed
|
||||
DimCase{SpvDim1D, false, true, ast::TextureDimension::k1d},
|
||||
DimCase{SpvDim2D, false, true, ast::TextureDimension::k2d},
|
||||
DimCase{SpvDim3D, false, true, ast::TextureDimension::k3d},
|
||||
DimCase{SpvDimCube, false, true, ast::TextureDimension::kCube},
|
||||
DimCase{spv::Dim::Dim1D, false, true, ast::TextureDimension::k1d},
|
||||
DimCase{spv::Dim::Dim2D, false, true, ast::TextureDimension::k2d},
|
||||
DimCase{spv::Dim::Dim3D, false, true, ast::TextureDimension::k3d},
|
||||
DimCase{spv::Dim::Cube, false, true, ast::TextureDimension::kCube},
|
||||
// Arrayed
|
||||
DimCase{SpvDim2D, true, true, ast::TextureDimension::k2dArray},
|
||||
DimCase{SpvDimCube, true, true, ast::TextureDimension::kCubeArray}));
|
||||
DimCase{spv::Dim::Dim2D, true, true, ast::TextureDimension::k2dArray},
|
||||
DimCase{spv::Dim::Cube, true, true,
|
||||
ast::TextureDimension::kCubeArray}));
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(EnumConverterBad,
|
||||
SpvDimTest,
|
||||
testing::Values(
|
||||
// Invalid SPIR-V dimensionality.
|
||||
DimCase{SpvDimMax, false, false, ast::TextureDimension::kNone},
|
||||
DimCase{SpvDimMax, true, false, ast::TextureDimension::kNone},
|
||||
// Vulkan non-arrayed dimensionalities not supported by WGSL.
|
||||
DimCase{SpvDimRect, false, false, ast::TextureDimension::kNone},
|
||||
DimCase{SpvDimBuffer, false, false, ast::TextureDimension::kNone},
|
||||
DimCase{SpvDimSubpassData, false, false, ast::TextureDimension::kNone},
|
||||
// Arrayed dimensionalities not supported by WGSL
|
||||
DimCase{SpvDim3D, true, false, ast::TextureDimension::kNone},
|
||||
DimCase{SpvDimRect, true, false, ast::TextureDimension::kNone},
|
||||
DimCase{SpvDimBuffer, true, false, ast::TextureDimension::kNone},
|
||||
DimCase{SpvDimSubpassData, true, false,
|
||||
ast::TextureDimension::kNone}));
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
EnumConverterBad,
|
||||
SpvDimTest,
|
||||
testing::Values(
|
||||
// Invalid SPIR-V dimensionality.
|
||||
DimCase{spv::Dim::Max, false, false, ast::TextureDimension::kNone},
|
||||
DimCase{spv::Dim::Max, true, false, ast::TextureDimension::kNone},
|
||||
// Vulkan non-arrayed dimensionalities not supported by WGSL.
|
||||
DimCase{spv::Dim::Rect, false, false, ast::TextureDimension::kNone},
|
||||
DimCase{spv::Dim::Buffer, false, false, ast::TextureDimension::kNone},
|
||||
DimCase{spv::Dim::SubpassData, false, false, ast::TextureDimension::kNone},
|
||||
// Arrayed dimensionalities not supported by WGSL
|
||||
DimCase{spv::Dim::Dim3D, true, false, ast::TextureDimension::kNone},
|
||||
DimCase{spv::Dim::Rect, true, false, ast::TextureDimension::kNone},
|
||||
DimCase{spv::Dim::Buffer, true, false, ast::TextureDimension::kNone},
|
||||
DimCase{spv::Dim::SubpassData, true, false, ast::TextureDimension::kNone}));
|
||||
|
||||
// TexelFormat
|
||||
|
||||
struct TexelFormatCase {
|
||||
SpvImageFormat format;
|
||||
spv::ImageFormat format;
|
||||
bool expect_success;
|
||||
ast::TexelFormat expected;
|
||||
};
|
||||
inline std::ostream& operator<<(std::ostream& out, TexelFormatCase ifc) {
|
||||
out << "TexelFormatCase{ SpvImageFormat:" << int(ifc.format)
|
||||
out << "TexelFormatCase{ spv::ImageFormat:::" << int(ifc.format)
|
||||
<< " expect_success?:" << int(ifc.expect_success) << " expected:" << int(ifc.expected)
|
||||
<< "}";
|
||||
return out;
|
||||
|
@ -328,52 +330,52 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
SpvImageFormatTest,
|
||||
testing::Values(
|
||||
// Unknown. This is used for sampled images.
|
||||
TexelFormatCase{SpvImageFormatUnknown, true, ast::TexelFormat::kUndefined},
|
||||
TexelFormatCase{spv::ImageFormat::Unknown, true, ast::TexelFormat::kUndefined},
|
||||
// 8 bit channels
|
||||
TexelFormatCase{SpvImageFormatRgba8, true, ast::TexelFormat::kRgba8Unorm},
|
||||
TexelFormatCase{SpvImageFormatRgba8Snorm, true, ast::TexelFormat::kRgba8Snorm},
|
||||
TexelFormatCase{SpvImageFormatRgba8ui, true, ast::TexelFormat::kRgba8Uint},
|
||||
TexelFormatCase{SpvImageFormatRgba8i, true, ast::TexelFormat::kRgba8Sint},
|
||||
TexelFormatCase{spv::ImageFormat::Rgba8, true, ast::TexelFormat::kRgba8Unorm},
|
||||
TexelFormatCase{spv::ImageFormat::Rgba8Snorm, true, ast::TexelFormat::kRgba8Snorm},
|
||||
TexelFormatCase{spv::ImageFormat::Rgba8ui, true, ast::TexelFormat::kRgba8Uint},
|
||||
TexelFormatCase{spv::ImageFormat::Rgba8i, true, ast::TexelFormat::kRgba8Sint},
|
||||
// 16 bit channels
|
||||
TexelFormatCase{SpvImageFormatRgba16ui, true, ast::TexelFormat::kRgba16Uint},
|
||||
TexelFormatCase{SpvImageFormatRgba16i, true, ast::TexelFormat::kRgba16Sint},
|
||||
TexelFormatCase{SpvImageFormatRgba16f, true, ast::TexelFormat::kRgba16Float},
|
||||
TexelFormatCase{spv::ImageFormat::Rgba16ui, true, ast::TexelFormat::kRgba16Uint},
|
||||
TexelFormatCase{spv::ImageFormat::Rgba16i, true, ast::TexelFormat::kRgba16Sint},
|
||||
TexelFormatCase{spv::ImageFormat::Rgba16f, true, ast::TexelFormat::kRgba16Float},
|
||||
// 32 bit channels
|
||||
// ... 1 channel
|
||||
TexelFormatCase{SpvImageFormatR32ui, true, ast::TexelFormat::kR32Uint},
|
||||
TexelFormatCase{SpvImageFormatR32i, true, ast::TexelFormat::kR32Sint},
|
||||
TexelFormatCase{SpvImageFormatR32f, true, ast::TexelFormat::kR32Float},
|
||||
TexelFormatCase{spv::ImageFormat::R32ui, true, ast::TexelFormat::kR32Uint},
|
||||
TexelFormatCase{spv::ImageFormat::R32i, true, ast::TexelFormat::kR32Sint},
|
||||
TexelFormatCase{spv::ImageFormat::R32f, true, ast::TexelFormat::kR32Float},
|
||||
// ... 2 channels
|
||||
TexelFormatCase{SpvImageFormatRg32ui, true, ast::TexelFormat::kRg32Uint},
|
||||
TexelFormatCase{SpvImageFormatRg32i, true, ast::TexelFormat::kRg32Sint},
|
||||
TexelFormatCase{SpvImageFormatRg32f, true, ast::TexelFormat::kRg32Float},
|
||||
TexelFormatCase{spv::ImageFormat::Rg32ui, true, ast::TexelFormat::kRg32Uint},
|
||||
TexelFormatCase{spv::ImageFormat::Rg32i, true, ast::TexelFormat::kRg32Sint},
|
||||
TexelFormatCase{spv::ImageFormat::Rg32f, true, ast::TexelFormat::kRg32Float},
|
||||
// ... 4 channels
|
||||
TexelFormatCase{SpvImageFormatRgba32ui, true, ast::TexelFormat::kRgba32Uint},
|
||||
TexelFormatCase{SpvImageFormatRgba32i, true, ast::TexelFormat::kRgba32Sint},
|
||||
TexelFormatCase{SpvImageFormatRgba32f, true, ast::TexelFormat::kRgba32Float}));
|
||||
TexelFormatCase{spv::ImageFormat::Rgba32ui, true, ast::TexelFormat::kRgba32Uint},
|
||||
TexelFormatCase{spv::ImageFormat::Rgba32i, true, ast::TexelFormat::kRgba32Sint},
|
||||
TexelFormatCase{spv::ImageFormat::Rgba32f, true, ast::TexelFormat::kRgba32Float}));
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
EnumConverterBad,
|
||||
SpvImageFormatTest,
|
||||
testing::Values(
|
||||
// Scanning in order from the SPIR-V spec.
|
||||
TexelFormatCase{SpvImageFormatRg16f, false, ast::TexelFormat::kUndefined},
|
||||
TexelFormatCase{SpvImageFormatR11fG11fB10f, false, ast::TexelFormat::kUndefined},
|
||||
TexelFormatCase{SpvImageFormatR16f, false, ast::TexelFormat::kUndefined},
|
||||
TexelFormatCase{SpvImageFormatRgb10A2, false, ast::TexelFormat::kUndefined},
|
||||
TexelFormatCase{SpvImageFormatRg16, false, ast::TexelFormat::kUndefined},
|
||||
TexelFormatCase{SpvImageFormatRg8, false, ast::TexelFormat::kUndefined},
|
||||
TexelFormatCase{SpvImageFormatR16, false, ast::TexelFormat::kUndefined},
|
||||
TexelFormatCase{SpvImageFormatR8, false, ast::TexelFormat::kUndefined},
|
||||
TexelFormatCase{SpvImageFormatRgba16Snorm, false, ast::TexelFormat::kUndefined},
|
||||
TexelFormatCase{SpvImageFormatRg16Snorm, false, ast::TexelFormat::kUndefined},
|
||||
TexelFormatCase{SpvImageFormatRg8Snorm, false, ast::TexelFormat::kUndefined},
|
||||
TexelFormatCase{SpvImageFormatRg16i, false, ast::TexelFormat::kUndefined},
|
||||
TexelFormatCase{SpvImageFormatRg8i, false, ast::TexelFormat::kUndefined},
|
||||
TexelFormatCase{SpvImageFormatR8i, false, ast::TexelFormat::kUndefined},
|
||||
TexelFormatCase{SpvImageFormatRgb10a2ui, false, ast::TexelFormat::kUndefined},
|
||||
TexelFormatCase{SpvImageFormatRg16ui, false, ast::TexelFormat::kUndefined},
|
||||
TexelFormatCase{SpvImageFormatRg8ui, false, ast::TexelFormat::kUndefined}));
|
||||
TexelFormatCase{spv::ImageFormat::Rg16f, false, ast::TexelFormat::kUndefined},
|
||||
TexelFormatCase{spv::ImageFormat::R11fG11fB10f, false, ast::TexelFormat::kUndefined},
|
||||
TexelFormatCase{spv::ImageFormat::R16f, false, ast::TexelFormat::kUndefined},
|
||||
TexelFormatCase{spv::ImageFormat::Rgb10A2, false, ast::TexelFormat::kUndefined},
|
||||
TexelFormatCase{spv::ImageFormat::Rg16, false, ast::TexelFormat::kUndefined},
|
||||
TexelFormatCase{spv::ImageFormat::Rg8, false, ast::TexelFormat::kUndefined},
|
||||
TexelFormatCase{spv::ImageFormat::R16, false, ast::TexelFormat::kUndefined},
|
||||
TexelFormatCase{spv::ImageFormat::R8, false, ast::TexelFormat::kUndefined},
|
||||
TexelFormatCase{spv::ImageFormat::Rgba16Snorm, false, ast::TexelFormat::kUndefined},
|
||||
TexelFormatCase{spv::ImageFormat::Rg16Snorm, false, ast::TexelFormat::kUndefined},
|
||||
TexelFormatCase{spv::ImageFormat::Rg8Snorm, false, ast::TexelFormat::kUndefined},
|
||||
TexelFormatCase{spv::ImageFormat::Rg16i, false, ast::TexelFormat::kUndefined},
|
||||
TexelFormatCase{spv::ImageFormat::Rg8i, false, ast::TexelFormat::kUndefined},
|
||||
TexelFormatCase{spv::ImageFormat::R8i, false, ast::TexelFormat::kUndefined},
|
||||
TexelFormatCase{spv::ImageFormat::Rgb10a2ui, false, ast::TexelFormat::kUndefined},
|
||||
TexelFormatCase{spv::ImageFormat::Rg16ui, false, ast::TexelFormat::kUndefined},
|
||||
TexelFormatCase{spv::ImageFormat::Rg8ui, false, ast::TexelFormat::kUndefined}));
|
||||
|
||||
} // namespace
|
||||
} // namespace tint::reader::spirv
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -66,8 +66,8 @@ namespace tint::reader::spirv {
|
|||
|
||||
/// The binary representation of a SPIR-V decoration enum followed by its
|
||||
/// operands, if any.
|
||||
/// Example: { SpvDecorationBlock }
|
||||
/// Example: { SpvDecorationArrayStride, 16 }
|
||||
/// Example: { spv::Decoration::Block }
|
||||
/// Example: { spv::Decoration::ArrayStride, 16 }
|
||||
using Decoration = std::vector<uint32_t>;
|
||||
|
||||
/// DecorationList is a list of decorations
|
||||
|
@ -338,13 +338,13 @@ class ParserImpl : Reader {
|
|||
/// Returns true when the given instruction is an extended instruction
|
||||
/// for GLSL.std.450.
|
||||
/// @param inst a SPIR-V instruction
|
||||
/// @returns true if its an SpvOpExtInst for GLSL.std.450
|
||||
/// @returns true if its an spv::Op::ExtInst for GLSL.std.450
|
||||
bool IsGlslExtendedInstruction(const spvtools::opt::Instruction& inst) const;
|
||||
|
||||
/// Returns true when the given instruction is an extended instruction
|
||||
/// from an ignored extended instruction set.
|
||||
/// @param inst a SPIR-V instruction
|
||||
/// @returns true if its an SpvOpExtInst for an ignored extended instruction
|
||||
/// @returns true if its an spv::Op::ExtInst for an ignored extended instruction
|
||||
bool IsIgnoredExtendedInstruction(const spvtools::opt::Instruction& inst) const;
|
||||
|
||||
/// Registers user names for SPIR-V objects, from OpName, and OpMemberName.
|
||||
|
@ -585,7 +585,7 @@ class ParserImpl : Reader {
|
|||
/// class class.
|
||||
uint32_t pointer_type_id = 0;
|
||||
/// The SPIR-V address space.
|
||||
SpvStorageClass storage_class = SpvStorageClassOutput;
|
||||
spv::StorageClass storage_class = spv::StorageClass::Output;
|
||||
/// The ID of the type of a pointer to the Position member.
|
||||
uint32_t position_member_pointer_type_id = 0;
|
||||
/// The ID of the gl_PerVertex variable, if it was declared.
|
||||
|
@ -690,7 +690,7 @@ class ParserImpl : Reader {
|
|||
const spvtools::opt::Instruction* GetInstructionForTest(uint32_t id) const;
|
||||
|
||||
/// A map of SPIR-V identifiers to builtins
|
||||
using BuiltInsMap = std::unordered_map<uint32_t, SpvBuiltIn>;
|
||||
using BuiltInsMap = std::unordered_map<uint32_t, spv::BuiltIn>;
|
||||
|
||||
/// @returns a map of builtins that should be handled specially by code
|
||||
/// generation. Either the builtin does not exist in WGSL, or a type
|
||||
|
@ -699,7 +699,7 @@ class ParserImpl : Reader {
|
|||
|
||||
/// @param builtin the SPIR-V builtin variable kind
|
||||
/// @returns the SPIR-V ID for the variable defining the given builtin, or 0
|
||||
uint32_t IdForSpecialBuiltIn(SpvBuiltIn builtin) const {
|
||||
uint32_t IdForSpecialBuiltIn(spv::BuiltIn builtin) const {
|
||||
// Do a linear search.
|
||||
for (const auto& entry : special_builtins_) {
|
||||
if (entry.second == builtin) {
|
||||
|
|
|
@ -31,7 +31,7 @@ TEST_F(SpvParserTest, ConvertMemberDecoration_IsEmpty) {
|
|||
TEST_F(SpvParserTest, ConvertMemberDecoration_OffsetWithoutOperand) {
|
||||
auto p = parser(std::vector<uint32_t>{});
|
||||
|
||||
auto result = p->ConvertMemberDecoration(12, 13, nullptr, {SpvDecorationOffset});
|
||||
auto result = p->ConvertMemberDecoration(12, 13, nullptr, {uint32_t(spv::Decoration::Offset)});
|
||||
EXPECT_TRUE(result.IsEmpty());
|
||||
EXPECT_THAT(p->error(), Eq("malformed Offset decoration: expected 1 literal "
|
||||
"operand, has 0: member 13 of SPIR-V type 12"));
|
||||
|
@ -40,7 +40,8 @@ TEST_F(SpvParserTest, ConvertMemberDecoration_OffsetWithoutOperand) {
|
|||
TEST_F(SpvParserTest, ConvertMemberDecoration_OffsetWithTooManyOperands) {
|
||||
auto p = parser(std::vector<uint32_t>{});
|
||||
|
||||
auto result = p->ConvertMemberDecoration(12, 13, nullptr, {SpvDecorationOffset, 3, 4});
|
||||
auto result =
|
||||
p->ConvertMemberDecoration(12, 13, nullptr, {uint32_t(spv::Decoration::Offset), 3, 4});
|
||||
EXPECT_TRUE(result.IsEmpty());
|
||||
EXPECT_THAT(p->error(), Eq("malformed Offset decoration: expected 1 literal "
|
||||
"operand, has 2: member 13 of SPIR-V type 12"));
|
||||
|
@ -49,7 +50,7 @@ TEST_F(SpvParserTest, ConvertMemberDecoration_OffsetWithTooManyOperands) {
|
|||
TEST_F(SpvParserTest, ConvertMemberDecoration_Offset) {
|
||||
auto p = parser(std::vector<uint32_t>{});
|
||||
|
||||
auto result = p->ConvertMemberDecoration(1, 1, nullptr, {SpvDecorationOffset, 8});
|
||||
auto result = p->ConvertMemberDecoration(1, 1, nullptr, {uint32_t(spv::Decoration::Offset), 8});
|
||||
ASSERT_FALSE(result.IsEmpty());
|
||||
EXPECT_TRUE(result[0]->Is<ast::StructMemberOffsetAttribute>());
|
||||
auto* offset_deco = result[0]->As<ast::StructMemberOffsetAttribute>();
|
||||
|
@ -64,7 +65,8 @@ TEST_F(SpvParserTest, ConvertMemberDecoration_Matrix2x2_Stride_Natural) {
|
|||
|
||||
spirv::F32 f32;
|
||||
spirv::Matrix matrix(&f32, 2, 2);
|
||||
auto result = p->ConvertMemberDecoration(1, 1, &matrix, {SpvDecorationMatrixStride, 8});
|
||||
auto result =
|
||||
p->ConvertMemberDecoration(1, 1, &matrix, {uint32_t(spv::Decoration::MatrixStride), 8});
|
||||
EXPECT_TRUE(result.IsEmpty());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
}
|
||||
|
@ -74,7 +76,8 @@ TEST_F(SpvParserTest, ConvertMemberDecoration_Matrix2x2_Stride_Custom) {
|
|||
|
||||
spirv::F32 f32;
|
||||
spirv::Matrix matrix(&f32, 2, 2);
|
||||
auto result = p->ConvertMemberDecoration(1, 1, &matrix, {SpvDecorationMatrixStride, 16});
|
||||
auto result =
|
||||
p->ConvertMemberDecoration(1, 1, &matrix, {uint32_t(spv::Decoration::MatrixStride), 16});
|
||||
ASSERT_FALSE(result.IsEmpty());
|
||||
EXPECT_TRUE(result[0]->Is<ast::StrideAttribute>());
|
||||
auto* stride_deco = result[0]->As<ast::StrideAttribute>();
|
||||
|
@ -88,7 +91,8 @@ TEST_F(SpvParserTest, ConvertMemberDecoration_Matrix2x4_Stride_Natural) {
|
|||
|
||||
spirv::F32 f32;
|
||||
spirv::Matrix matrix(&f32, 2, 4);
|
||||
auto result = p->ConvertMemberDecoration(1, 1, &matrix, {SpvDecorationMatrixStride, 16});
|
||||
auto result =
|
||||
p->ConvertMemberDecoration(1, 1, &matrix, {uint32_t(spv::Decoration::MatrixStride), 16});
|
||||
EXPECT_TRUE(result.IsEmpty());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
}
|
||||
|
@ -98,7 +102,8 @@ TEST_F(SpvParserTest, ConvertMemberDecoration_Matrix2x4_Stride_Custom) {
|
|||
|
||||
spirv::F32 f32;
|
||||
spirv::Matrix matrix(&f32, 2, 4);
|
||||
auto result = p->ConvertMemberDecoration(1, 1, &matrix, {SpvDecorationMatrixStride, 64});
|
||||
auto result =
|
||||
p->ConvertMemberDecoration(1, 1, &matrix, {uint32_t(spv::Decoration::MatrixStride), 64});
|
||||
ASSERT_FALSE(result.IsEmpty());
|
||||
EXPECT_TRUE(result[0]->Is<ast::StrideAttribute>());
|
||||
auto* stride_deco = result[0]->As<ast::StrideAttribute>();
|
||||
|
@ -112,7 +117,8 @@ TEST_F(SpvParserTest, ConvertMemberDecoration_Matrix2x3_Stride_Custom) {
|
|||
|
||||
spirv::F32 f32;
|
||||
spirv::Matrix matrix(&f32, 2, 3);
|
||||
auto result = p->ConvertMemberDecoration(1, 1, &matrix, {SpvDecorationMatrixStride, 32});
|
||||
auto result =
|
||||
p->ConvertMemberDecoration(1, 1, &matrix, {uint32_t(spv::Decoration::MatrixStride), 32});
|
||||
ASSERT_FALSE(result.IsEmpty());
|
||||
EXPECT_TRUE(result[0]->Is<ast::StrideAttribute>());
|
||||
auto* stride_deco = result[0]->As<ast::StrideAttribute>();
|
||||
|
@ -127,7 +133,8 @@ TEST_F(SpvParserTest, ConvertMemberDecoration_RelaxedPrecision) {
|
|||
// relaxed precision f32.
|
||||
auto p = parser(std::vector<uint32_t>{});
|
||||
|
||||
auto result = p->ConvertMemberDecoration(1, 1, nullptr, {SpvDecorationRelaxedPrecision});
|
||||
auto result =
|
||||
p->ConvertMemberDecoration(1, 1, nullptr, {uint32_t(spv::Decoration::RelaxedPrecision)});
|
||||
EXPECT_TRUE(result.IsEmpty());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ TEST_F(SpvParserGetDecorationsTest, GetDecorationsFor_OneDecoration) {
|
|||
)"));
|
||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||
auto decorations = p->GetDecorationsFor(10);
|
||||
EXPECT_THAT(decorations, UnorderedElementsAre(Decoration{SpvDecorationBlock}));
|
||||
EXPECT_THAT(decorations, UnorderedElementsAre(Decoration{uint32_t(spv::Decoration::Block)}));
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
p->SkipDumpingPending(kSkipReason);
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ TEST_F(SpvParserGetDecorationsTest, GetDecorationsFor_Duplicate) {
|
|||
)"));
|
||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||
auto decorations = p->GetDecorationsFor(10);
|
||||
EXPECT_THAT(decorations, UnorderedElementsAre(Decoration{SpvDecorationBlock}));
|
||||
EXPECT_THAT(decorations, UnorderedElementsAre(Decoration{uint32_t(spv::Decoration::Block)}));
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
p->SkipDumpingPending(kSkipReason);
|
||||
}
|
||||
|
@ -80,8 +80,9 @@ TEST_F(SpvParserGetDecorationsTest, GetDecorationsFor_MultiDecoration) {
|
|||
)"));
|
||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||
auto decorations = p->GetDecorationsFor(5);
|
||||
EXPECT_THAT(decorations, UnorderedElementsAre(Decoration{SpvDecorationRelaxedPrecision},
|
||||
Decoration{SpvDecorationLocation, 7}));
|
||||
EXPECT_THAT(decorations,
|
||||
UnorderedElementsAre(Decoration{uint32_t(spv::Decoration::RelaxedPrecision)},
|
||||
Decoration{uint32_t(spv::Decoration::Location), 7}));
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
p->SkipDumpingPending(kSkipReason);
|
||||
}
|
||||
|
@ -124,7 +125,8 @@ TEST_F(SpvParserGetDecorationsTest, GetDecorationsForMember_RelaxedPrecision) {
|
|||
)"));
|
||||
EXPECT_TRUE(p->BuildAndParseInternalModule()) << p->error();
|
||||
auto decorations = p->GetDecorationsForMember(10, 0);
|
||||
EXPECT_THAT(decorations, UnorderedElementsAre(Decoration{SpvDecorationRelaxedPrecision}));
|
||||
EXPECT_THAT(decorations,
|
||||
UnorderedElementsAre(Decoration{uint32_t(spv::Decoration::RelaxedPrecision)}));
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
p->SkipDumpingPending(kSkipReason);
|
||||
}
|
||||
|
@ -138,7 +140,8 @@ TEST_F(SpvParserGetDecorationsTest, GetDecorationsForMember_Duplicate) {
|
|||
)"));
|
||||
EXPECT_TRUE(p->BuildAndParseInternalModule()) << p->error();
|
||||
auto decorations = p->GetDecorationsForMember(10, 0);
|
||||
EXPECT_THAT(decorations, UnorderedElementsAre(Decoration{SpvDecorationRelaxedPrecision}));
|
||||
EXPECT_THAT(decorations,
|
||||
UnorderedElementsAre(Decoration{uint32_t(spv::Decoration::RelaxedPrecision)}));
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
p->SkipDumpingPending(kSkipReason);
|
||||
}
|
||||
|
@ -154,7 +157,8 @@ TEST_F(SpvParserGetDecorationsTest, DISABLED_GetDecorationsForMember_OneDecorati
|
|||
)"));
|
||||
EXPECT_TRUE(p->BuildAndParseInternalModule()) << p->error();
|
||||
auto decorations = p->GetDecorationsForMember(10, 1);
|
||||
EXPECT_THAT(decorations, UnorderedElementsAre(Decoration{SpvDecorationArrayStride, 12}));
|
||||
EXPECT_THAT(decorations,
|
||||
UnorderedElementsAre(Decoration{uint32_t(spv::Decoration::ArrayStride), 12}));
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
}
|
||||
|
||||
|
@ -179,11 +183,11 @@ TEST_F(SpvParserGetDecorationsTest, DISABLED_GetDecorationsForMember_MultiDecora
|
|||
|
||||
EXPECT_TRUE(p->GetDecorationsForMember(50, 0).empty());
|
||||
EXPECT_THAT(p->GetDecorationsForMember(50, 1),
|
||||
UnorderedElementsAre(Decoration{SpvDecorationRelaxedPrecision}));
|
||||
UnorderedElementsAre(Decoration{uint32_t(spv::Decoration::RelaxedPrecision)}));
|
||||
EXPECT_THAT(p->GetDecorationsForMember(50, 2),
|
||||
UnorderedElementsAre(Decoration{SpvDecorationColMajor},
|
||||
Decoration{SpvDecorationMatrixStride, 8},
|
||||
Decoration{SpvDecorationArrayStride, 16}));
|
||||
UnorderedElementsAre(Decoration{uint32_t(spv::Decoration::ColMajor)},
|
||||
Decoration{uint32_t(spv::Decoration::MatrixStride), 8},
|
||||
Decoration{uint32_t(spv::Decoration::ArrayStride), 16}));
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue