spirv-reader: Support multisampled textures
Only ImageFetch is supported. Converts the signedness of the sample operand as needed. Bug: tint:109 Bug: dawn:399 Change-Id: I1d00ff4452af123457bb1841d872afcf2c591c48 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35540 Auto-Submit: David Neto <dneto@google.com> Reviewed-by: Ben Clayton <bclayton@google.com> Commit-Queue: David Neto <dneto@google.com>
This commit is contained in:
parent
a80511e021
commit
cd9e5f6e91
|
@ -3947,10 +3947,23 @@ bool FunctionEmitter::EmitImageAccess(const spvtools::opt::Instruction& inst) {
|
|||
}
|
||||
if (arg_index < num_args &&
|
||||
(image_operands_mask & SpvImageOperandsConstOffsetMask)) {
|
||||
// TODO(dneto): convert to signed integer if needed
|
||||
params.push_back(MakeOperand(inst, arg_index).expr);
|
||||
image_operands_mask ^= SpvImageOperandsConstOffsetMask;
|
||||
arg_index++;
|
||||
}
|
||||
if (arg_index < num_args &&
|
||||
(image_operands_mask & SpvImageOperandsSampleMask)) {
|
||||
TypedExpression sample = MakeOperand(inst, arg_index);
|
||||
if (!sample.type->Is<ast::type::I32>()) {
|
||||
sample.expr = ast_module_.create<ast::TypeConstructorExpression>(
|
||||
ast_module_.create<ast::type::I32>(),
|
||||
ast::ExpressionList{sample.expr});
|
||||
}
|
||||
params.push_back(sample.expr);
|
||||
image_operands_mask ^= SpvImageOperandsSampleMask;
|
||||
arg_index++;
|
||||
}
|
||||
if (image_operands_mask) {
|
||||
return Fail() << "unsupported image operands (" << image_operands_mask
|
||||
<< "): " << inst.PrettyPrint();
|
||||
|
|
|
@ -2934,6 +2934,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
}
|
||||
})"},
|
||||
// OpImageFetch with ConstOffset
|
||||
// TODO(dneto): Seems this is not valid in WGSL.
|
||||
{"%float 2D 0 0 0 1 Unknown",
|
||||
"%99 = OpImageFetch %v4float %im %vu12 ConstOffset %offsets2d",
|
||||
R"(Variable{
|
||||
|
@ -2963,6 +2964,118 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
}
|
||||
})"}}));
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
ImageFetch_Multisampled,
|
||||
SpvParserTest_ImageAccessTest,
|
||||
::testing::ValuesIn(std::vector<ImageAccessCase>{
|
||||
// SPIR-V requires a Sample image operand when operating on a
|
||||
// multisampled image.
|
||||
|
||||
// ImageFetch non-arrayed
|
||||
{"%float 2D 0 0 1 1 Unknown",
|
||||
"%99 = OpImageFetch %v4float %im %vi12 Sample %i1",
|
||||
R"(Variable{
|
||||
Decorations{
|
||||
SetDecoration{2}
|
||||
BindingDecoration{1}
|
||||
}
|
||||
x_20
|
||||
uniform_constant
|
||||
__multisampled_texture_2d__f32
|
||||
})",
|
||||
R"(VariableDeclStatement{
|
||||
VariableConst{
|
||||
x_99
|
||||
none
|
||||
__vec_4__f32
|
||||
{
|
||||
Call[not set]{
|
||||
Identifier[not set]{textureLoad}
|
||||
(
|
||||
Identifier[not set]{x_20}
|
||||
Identifier[not set]{vi12}
|
||||
Identifier[not set]{i1}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
})"},
|
||||
// ImageFetch arrayed
|
||||
{"%float 2D 0 1 1 1 Unknown",
|
||||
"%99 = OpImageFetch %v4float %im %vi123 Sample %i1",
|
||||
R"(Variable{
|
||||
Decorations{
|
||||
SetDecoration{2}
|
||||
BindingDecoration{1}
|
||||
}
|
||||
x_20
|
||||
uniform_constant
|
||||
__multisampled_texture_2d_array__f32
|
||||
})",
|
||||
R"(VariableDeclStatement{
|
||||
VariableConst{
|
||||
x_99
|
||||
none
|
||||
__vec_4__f32
|
||||
{
|
||||
Call[not set]{
|
||||
Identifier[not set]{textureLoad}
|
||||
(
|
||||
Identifier[not set]{x_20}
|
||||
MemberAccessor[not set]{
|
||||
Identifier[not set]{vi123}
|
||||
Identifier[not set]{xy}
|
||||
}
|
||||
TypeConstructor[not set]{
|
||||
__i32
|
||||
MemberAccessor[not set]{
|
||||
Identifier[not set]{vi123}
|
||||
Identifier[not set]{z}
|
||||
}
|
||||
}
|
||||
Identifier[not set]{i1}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
})"}}));
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
ImageFetch_Multisampled_ConvertSampleOperand,
|
||||
SpvParserTest_ImageAccessTest,
|
||||
::testing::ValuesIn(std::vector<ImageAccessCase>{
|
||||
{"%float 2D 0 0 1 1 Unknown",
|
||||
"%99 = OpImageFetch %v4float %im %vi12 Sample %u1",
|
||||
R"(Variable{
|
||||
Decorations{
|
||||
SetDecoration{2}
|
||||
BindingDecoration{1}
|
||||
}
|
||||
x_20
|
||||
uniform_constant
|
||||
__multisampled_texture_2d__f32
|
||||
})",
|
||||
R"(VariableDeclStatement{
|
||||
VariableConst{
|
||||
x_99
|
||||
none
|
||||
__vec_4__f32
|
||||
{
|
||||
Call[not set]{
|
||||
Identifier[not set]{textureLoad}
|
||||
(
|
||||
Identifier[not set]{x_20}
|
||||
Identifier[not set]{vi12}
|
||||
TypeConstructor[not set]{
|
||||
__i32
|
||||
Identifier[not set]{u1}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
})"}}));
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
ConvertResultSignedness,
|
||||
SpvParserTest_SampledImageAccessTest,
|
||||
|
|
Loading…
Reference in New Issue