spirv-reader: textureLoad explicit Lod sometimes
WGSL requires an explicit level-of-detail for textureLoad for sampled textures and depth textures Fixed: tint:462 Change-Id: I43758b002da91af9901d12664861ace971833020 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38828 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
34ac1afd99
commit
36194197ac
|
@ -68,6 +68,7 @@
|
|||
#include "src/type/i32_type.h"
|
||||
#include "src/type/matrix_type.h"
|
||||
#include "src/type/pointer_type.h"
|
||||
#include "src/type/sampled_texture_type.h"
|
||||
#include "src/type/storage_texture_type.h"
|
||||
#include "src/type/texture_type.h"
|
||||
#include "src/type/type.h"
|
||||
|
@ -4212,6 +4213,12 @@ bool FunctionEmitter::EmitImageAccess(const spvtools::opt::Instruction& inst) {
|
|||
params.push_back(lod.expr);
|
||||
image_operands_mask ^= SpvImageOperandsLodMask;
|
||||
arg_index++;
|
||||
} else if ((opcode == SpvOpImageFetch) &&
|
||||
(texture_type->Is<type::SampledTexture>() ||
|
||||
texture_type->Is<type::DepthTexture>())) {
|
||||
// textureLoad on sampled texture and depth texture requires an explicit
|
||||
// level-of-detail parameter.
|
||||
params.push_back(parser_impl_.MakeNullValue(i32_));
|
||||
}
|
||||
if (arg_index + 1 < num_args &&
|
||||
(image_operands_mask & SpvImageOperandsGradMask)) {
|
||||
|
|
|
@ -3036,7 +3036,8 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
ImageFetch_OptionalParams,
|
||||
SpvParserTest_ImageAccessTest,
|
||||
::testing::ValuesIn(std::vector<ImageAccessCase>{
|
||||
// OpImageFetch with no extra params
|
||||
// OpImageFetch with no extra params, on sampled texture
|
||||
// Level of detail is injected for sampled texture
|
||||
{"%float 2D 0 0 0 1 Unknown", "%99 = OpImageFetch %v4float %im %vi12",
|
||||
R"(Variable{
|
||||
Decorations{
|
||||
|
@ -3058,12 +3059,13 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
(
|
||||
Identifier[not set]{x_20}
|
||||
Identifier[not set]{vi12}
|
||||
ScalarConstructor[not set]{0}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
})"},
|
||||
// OpImageFetch with explicit level
|
||||
// OpImageFetch with explicit level, on sampled texture
|
||||
{"%float 2D 0 0 0 1 Unknown",
|
||||
"%99 = OpImageFetch %v4float %im %vi12 Lod %int_3",
|
||||
R"(Variable{
|
||||
|
@ -3091,6 +3093,76 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
}
|
||||
}
|
||||
}
|
||||
})"},
|
||||
// OpImageFetch with no extra params, on depth texture
|
||||
// Level of detail is injected for depth texture
|
||||
{"%float 2D 1 0 0 1 Unknown", "%99 = OpImageFetch %v4float %im %vi12",
|
||||
R"(Variable{
|
||||
Decorations{
|
||||
GroupDecoration{2}
|
||||
BindingDecoration{1}
|
||||
}
|
||||
x_20
|
||||
uniform_constant
|
||||
__depth_texture_2d
|
||||
})",
|
||||
R"(VariableDeclStatement{
|
||||
VariableConst{
|
||||
x_99
|
||||
none
|
||||
__vec_4__f32
|
||||
{
|
||||
TypeConstructor[not set]{
|
||||
__vec_4__f32
|
||||
Call[not set]{
|
||||
Identifier[not set]{textureLoad}
|
||||
(
|
||||
Identifier[not set]{x_20}
|
||||
Identifier[not set]{vi12}
|
||||
ScalarConstructor[not set]{0}
|
||||
)
|
||||
}
|
||||
ScalarConstructor[not set]{0.000000}
|
||||
ScalarConstructor[not set]{0.000000}
|
||||
ScalarConstructor[not set]{0.000000}
|
||||
}
|
||||
}
|
||||
}
|
||||
})"},
|
||||
// OpImageFetch with extra params, on depth texture
|
||||
{"%float 2D 1 0 0 1 Unknown",
|
||||
"%99 = OpImageFetch %v4float %im %vi12 Lod %int_3",
|
||||
R"(Variable{
|
||||
Decorations{
|
||||
GroupDecoration{2}
|
||||
BindingDecoration{1}
|
||||
}
|
||||
x_20
|
||||
uniform_constant
|
||||
__depth_texture_2d
|
||||
})",
|
||||
R"(VariableDeclStatement{
|
||||
VariableConst{
|
||||
x_99
|
||||
none
|
||||
__vec_4__f32
|
||||
{
|
||||
TypeConstructor[not set]{
|
||||
__vec_4__f32
|
||||
Call[not set]{
|
||||
Identifier[not set]{textureLoad}
|
||||
(
|
||||
Identifier[not set]{x_20}
|
||||
Identifier[not set]{vi12}
|
||||
ScalarConstructor[not set]{3}
|
||||
)
|
||||
}
|
||||
ScalarConstructor[not set]{0.000000}
|
||||
ScalarConstructor[not set]{0.000000}
|
||||
ScalarConstructor[not set]{0.000000}
|
||||
}
|
||||
}
|
||||
}
|
||||
})"}}));
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(ImageFetch_Depth,
|
||||
|
@ -3125,6 +3197,7 @@ INSTANTIATE_TEST_SUITE_P(ImageFetch_Depth,
|
|||
(
|
||||
Identifier[not set]{x_20}
|
||||
Identifier[not set]{vi12}
|
||||
ScalarConstructor[not set]{0}
|
||||
)
|
||||
}
|
||||
ScalarConstructor[not set]{0.000000}
|
||||
|
@ -3284,6 +3357,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
(
|
||||
Identifier[not set]{x_20}
|
||||
Identifier[not set]{vi12}
|
||||
ScalarConstructor[not set]{0}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -3311,6 +3385,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
(
|
||||
Identifier[not set]{x_20}
|
||||
Identifier[not set]{vi12}
|
||||
ScalarConstructor[not set]{0}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -3339,6 +3414,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
(
|
||||
Identifier[not set]{x_20}
|
||||
Identifier[not set]{vi12}
|
||||
ScalarConstructor[not set]{0}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -3367,6 +3443,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
(
|
||||
Identifier[not set]{x_20}
|
||||
Identifier[not set]{vi12}
|
||||
ScalarConstructor[not set]{0}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -3395,6 +3472,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
(
|
||||
Identifier[not set]{x_20}
|
||||
Identifier[not set]{vi12}
|
||||
ScalarConstructor[not set]{0}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue