spirv-reader: support textureLoad
Both OpImageRead and OpImageFetch map to WGSL textureLoad. Bug: tint:109 Change-Id: I3c99840c2e62c52dcaaf7177773a3c972de90cc1 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34425 Reviewed-by: dan sinclair <dsinclair@chromium.org> Commit-Queue: dan sinclair <dsinclair@chromium.org> Auto-Submit: David Neto <dneto@google.com>
This commit is contained in:
parent
91ad3961df
commit
782f6a5e3e
|
@ -3719,6 +3719,14 @@ bool FunctionEmitter::EmitImageAccess(const spvtools::opt::Instruction& inst) {
|
|||
return Fail() << " image gather is not yet supported";
|
||||
case SpvOpImageQueryLod:
|
||||
return Fail() << " image query Lod is not yet supported";
|
||||
case SpvOpImageFetch:
|
||||
// Read a single texel from a sampled image.
|
||||
builtin_name = "textureLoad";
|
||||
break;
|
||||
case SpvOpImageRead:
|
||||
// Read a single texel from a storage image.
|
||||
builtin_name = "textureLoad";
|
||||
break;
|
||||
case SpvOpImageWrite:
|
||||
builtin_name = "textureStore";
|
||||
if (arg_index < num_args) {
|
||||
|
|
|
@ -2823,6 +2823,128 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
)
|
||||
})"}}));
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
ImageRead_OptionalParams,
|
||||
SpvParserTest_ImageAccessTest,
|
||||
::testing::ValuesIn(std::vector<ImageAccessCase>{
|
||||
// OpImageRead with no extra params
|
||||
{"%float 2D 0 0 0 2 Rgba32f", "%99 = OpImageRead %v4float %im %vu12",
|
||||
R"(DecoratedVariable{
|
||||
Decorations{
|
||||
SetDecoration{2}
|
||||
BindingDecoration{1}
|
||||
}
|
||||
x_20
|
||||
uniform_constant
|
||||
__storage_texture_read_only_2d_rgba32float
|
||||
})",
|
||||
R"(VariableDeclStatement{
|
||||
VariableConst{
|
||||
x_99
|
||||
none
|
||||
__vec_4__f32
|
||||
{
|
||||
Call[not set]{
|
||||
Identifier[not set]{textureLoad}
|
||||
(
|
||||
Identifier[not set]{x_20}
|
||||
Identifier[not set]{vu12}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
})"},
|
||||
// OpImageRead with ConstOffset
|
||||
{"%float 2D 0 0 0 2 Rgba32f",
|
||||
"%99 = OpImageRead %v4float %im %vu12 ConstOffset %offsets2d",
|
||||
R"(DecoratedVariable{
|
||||
Decorations{
|
||||
SetDecoration{2}
|
||||
BindingDecoration{1}
|
||||
}
|
||||
x_20
|
||||
uniform_constant
|
||||
__storage_texture_read_only_2d_rgba32float
|
||||
})",
|
||||
R"(VariableDeclStatement{
|
||||
VariableConst{
|
||||
x_99
|
||||
none
|
||||
__vec_4__f32
|
||||
{
|
||||
Call[not set]{
|
||||
Identifier[not set]{textureLoad}
|
||||
(
|
||||
Identifier[not set]{x_20}
|
||||
Identifier[not set]{vu12}
|
||||
Identifier[not set]{offsets2d}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
})"}}));
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
ImageFetch_OptionalParams,
|
||||
SpvParserTest_ImageAccessTest,
|
||||
::testing::ValuesIn(std::vector<ImageAccessCase>{
|
||||
// OpImageFetch with no extra params
|
||||
{"%float 2D 0 0 0 1 Rgba32f", "%99 = OpImageFetch %v4float %im %vu12",
|
||||
R"(DecoratedVariable{
|
||||
Decorations{
|
||||
SetDecoration{2}
|
||||
BindingDecoration{1}
|
||||
}
|
||||
x_20
|
||||
uniform_constant
|
||||
__sampled_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]{vu12}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
})"},
|
||||
// OpImageFetch with ConstOffset
|
||||
{"%float 2D 0 0 0 1 Rgba32f",
|
||||
"%99 = OpImageFetch %v4float %im %vu12 ConstOffset %offsets2d",
|
||||
R"(DecoratedVariable{
|
||||
Decorations{
|
||||
SetDecoration{2}
|
||||
BindingDecoration{1}
|
||||
}
|
||||
x_20
|
||||
uniform_constant
|
||||
__sampled_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]{vu12}
|
||||
Identifier[not set]{offsets2d}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
})"}}));
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
// The SPIR-V result type could be integral but of different signedness
|
||||
// than the sampled texel type. In these cases the result should be
|
||||
|
|
Loading…
Reference in New Issue