mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-06-06 06:33:30 +00:00
spirv-reader: textureDimensions returns 3-elem vec for Cube,CubeArray
Fixed: tint:787 Bug: tint:765 Change-Id: If5cebb21bf169765f3baf8a5aec4a3dace19d707 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50601 Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Antonio Maiorano <amaiorano@google.com> Commit-Queue: David Neto <dneto@google.com>
This commit is contained in:
parent
b5236b2783
commit
facd33199a
@ -4755,9 +4755,17 @@ bool FunctionEmitter::EmitImageQuery(const spvtools::opt::Instruction& inst) {
|
|||||||
if (opcode == SpvOpImageQuerySizeLod) {
|
if (opcode == SpvOpImageQuerySizeLod) {
|
||||||
dims_args.push_back(ToI32(MakeOperand(inst, 1)).expr);
|
dims_args.push_back(ToI32(MakeOperand(inst, 1)).expr);
|
||||||
}
|
}
|
||||||
exprs.push_back(
|
ast::Expression* dims_call =
|
||||||
create<ast::CallExpression>(Source{}, dims_ident, dims_args));
|
create<ast::CallExpression>(Source{}, dims_ident, dims_args);
|
||||||
if (ast::IsTextureArray(texture_type->dims)) {
|
auto dims = texture_type->dims;
|
||||||
|
if ((dims == ast::TextureDimension::kCube) ||
|
||||||
|
(dims == ast::TextureDimension::kCubeArray)) {
|
||||||
|
// textureDimension returns a 3-element vector but SPIR-V expects 2.
|
||||||
|
dims_call = create<ast::MemberAccessorExpression>(Source{}, dims_call,
|
||||||
|
PrefixSwizzle(2));
|
||||||
|
}
|
||||||
|
exprs.push_back(dims_call);
|
||||||
|
if (ast::IsTextureArray(dims)) {
|
||||||
auto* layers_ident = create<ast::IdentifierExpression>(
|
auto* layers_ident = create<ast::IdentifierExpression>(
|
||||||
Source{}, builder_.Symbols().Register("textureNumLayers"));
|
Source{}, builder_.Symbols().Register("textureNumLayers"));
|
||||||
exprs.push_back(create<ast::CallExpression>(
|
exprs.push_back(create<ast::CallExpression>(
|
||||||
|
@ -1592,11 +1592,6 @@ TEST_P(SpvParserHandleTest_SampledImageAccessTest, Variable) {
|
|||||||
GetParam().spirv_image_access.find("ImageQuerySize") != std::string::npos;
|
GetParam().spirv_image_access.find("ImageQuerySize") != std::string::npos;
|
||||||
const bool is_1d =
|
const bool is_1d =
|
||||||
GetParam().spirv_image_type_details.find("1D") != std::string::npos;
|
GetParam().spirv_image_type_details.find("1D") != std::string::npos;
|
||||||
const bool is_cube =
|
|
||||||
GetParam().spirv_image_type_details.find("Cube") != std::string::npos;
|
|
||||||
if (is_query_size && is_cube) {
|
|
||||||
p->SkipDumpingPending("crbug.com/tint/787");
|
|
||||||
}
|
|
||||||
if (is_query_size && is_1d) {
|
if (is_query_size && is_1d) {
|
||||||
p->SkipDumpingPending("crbug.com/tint/788");
|
p->SkipDumpingPending("crbug.com/tint/788");
|
||||||
}
|
}
|
||||||
@ -4132,18 +4127,16 @@ INSTANTIATE_TEST_SUITE_P(
|
|||||||
// Not in WebGPU
|
// Not in WebGPU
|
||||||
}));
|
}));
|
||||||
|
|
||||||
INSTANTIATE_TEST_SUITE_P(
|
INSTANTIATE_TEST_SUITE_P(ImageQuerySizeLod_NonArrayed_SignedResult_SignedLevel,
|
||||||
ImageQuerySizeLod_NonArrayed_SignedResult_SignedLevel,
|
// From VUID-StandaloneSpirv-OpImageQuerySizeLod-04659:
|
||||||
// ImageQuerySize requires storage image or multisampled
|
// ImageQuerySizeLod requires Sampled=1
|
||||||
// For storage image, use another instruction to indicate whether it
|
SpvParserHandleTest_SampledImageAccessTest,
|
||||||
// is readonly or writeonly.
|
::testing::ValuesIn(std::vector<ImageAccessCase>{
|
||||||
SpvParserHandleTest_SampledImageAccessTest,
|
|
||||||
::testing::ValuesIn(std::vector<ImageAccessCase>{
|
|
||||||
|
|
||||||
// 1D
|
// 1D
|
||||||
{"%float 1D 0 0 0 1 Unknown",
|
{"%float 1D 0 0 0 1 Unknown",
|
||||||
"%99 = OpImageQuerySizeLod %int %im %i1\n",
|
"%99 = OpImageQuerySizeLod %int %im %i1\n",
|
||||||
R"(Variable{
|
R"(Variable{
|
||||||
Decorations{
|
Decorations{
|
||||||
GroupDecoration{2}
|
GroupDecoration{2}
|
||||||
BindingDecoration{1}
|
BindingDecoration{1}
|
||||||
@ -4152,7 +4145,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||||||
uniform_constant
|
uniform_constant
|
||||||
__sampled_texture_1d__f32
|
__sampled_texture_1d__f32
|
||||||
})",
|
})",
|
||||||
R"(VariableDeclStatement{
|
R"(VariableDeclStatement{
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_99
|
x_99
|
||||||
none
|
none
|
||||||
@ -4172,10 +4165,10 @@ INSTANTIATE_TEST_SUITE_P(
|
|||||||
}
|
}
|
||||||
})"},
|
})"},
|
||||||
|
|
||||||
// 2D
|
// 2D
|
||||||
{"%float 2D 0 0 0 1 Unknown",
|
{"%float 2D 0 0 0 1 Unknown",
|
||||||
"%99 = OpImageQuerySizeLod %v2int %im %i1\n",
|
"%99 = OpImageQuerySizeLod %v2int %im %i1\n",
|
||||||
R"(Variable{
|
R"(Variable{
|
||||||
Decorations{
|
Decorations{
|
||||||
GroupDecoration{2}
|
GroupDecoration{2}
|
||||||
BindingDecoration{1}
|
BindingDecoration{1}
|
||||||
@ -4184,7 +4177,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||||||
uniform_constant
|
uniform_constant
|
||||||
__sampled_texture_2d__f32
|
__sampled_texture_2d__f32
|
||||||
})",
|
})",
|
||||||
R"(VariableDeclStatement{
|
R"(VariableDeclStatement{
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_99
|
x_99
|
||||||
none
|
none
|
||||||
@ -4204,10 +4197,10 @@ INSTANTIATE_TEST_SUITE_P(
|
|||||||
}
|
}
|
||||||
})"},
|
})"},
|
||||||
|
|
||||||
// 3D
|
// 3D
|
||||||
{"%float 3D 0 0 0 1 Unknown",
|
{"%float 3D 0 0 0 1 Unknown",
|
||||||
"%99 = OpImageQuerySizeLod %v3int %im %i1\n",
|
"%99 = OpImageQuerySizeLod %v3int %im %i1\n",
|
||||||
R"(Variable{
|
R"(Variable{
|
||||||
Decorations{
|
Decorations{
|
||||||
GroupDecoration{2}
|
GroupDecoration{2}
|
||||||
BindingDecoration{1}
|
BindingDecoration{1}
|
||||||
@ -4216,7 +4209,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||||||
uniform_constant
|
uniform_constant
|
||||||
__sampled_texture_3d__f32
|
__sampled_texture_3d__f32
|
||||||
})",
|
})",
|
||||||
R"(VariableDeclStatement{
|
R"(VariableDeclStatement{
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_99
|
x_99
|
||||||
none
|
none
|
||||||
@ -4236,10 +4229,10 @@ INSTANTIATE_TEST_SUITE_P(
|
|||||||
}
|
}
|
||||||
})"},
|
})"},
|
||||||
|
|
||||||
// Cube
|
// Cube
|
||||||
{"%float Cube 0 0 0 1 Unknown",
|
{"%float Cube 0 0 0 1 Unknown",
|
||||||
"%99 = OpImageQuerySizeLod %v3int %im %i1\n",
|
"%99 = OpImageQuerySizeLod %v2int %im %i1\n",
|
||||||
R"(Variable{
|
R"(Variable{
|
||||||
Decorations{
|
Decorations{
|
||||||
GroupDecoration{2}
|
GroupDecoration{2}
|
||||||
BindingDecoration{1}
|
BindingDecoration{1}
|
||||||
@ -4248,30 +4241,33 @@ INSTANTIATE_TEST_SUITE_P(
|
|||||||
uniform_constant
|
uniform_constant
|
||||||
__sampled_texture_cube__f32
|
__sampled_texture_cube__f32
|
||||||
})",
|
})",
|
||||||
R"(VariableDeclStatement{
|
R"(VariableDeclStatement{
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_99
|
x_99
|
||||||
none
|
none
|
||||||
__vec_3__i32
|
__vec_2__i32
|
||||||
{
|
{
|
||||||
TypeConstructor[not set]{
|
TypeConstructor[not set]{
|
||||||
__vec_3__i32
|
__vec_2__i32
|
||||||
Call[not set]{
|
MemberAccessor[not set]{
|
||||||
Identifier[not set]{textureDimensions}
|
Call[not set]{
|
||||||
(
|
Identifier[not set]{textureDimensions}
|
||||||
Identifier[not set]{x_20}
|
(
|
||||||
Identifier[not set]{i1}
|
Identifier[not set]{x_20}
|
||||||
)
|
Identifier[not set]{i1}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Identifier[not set]{xy}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})"},
|
})"},
|
||||||
|
|
||||||
// Depth 2D
|
// Depth 2D
|
||||||
{"%float 2D 1 0 0 1 Unknown",
|
{"%float 2D 1 0 0 1 Unknown",
|
||||||
"%99 = OpImageQuerySizeLod %v2int %im %i1\n",
|
"%99 = OpImageQuerySizeLod %v2int %im %i1\n",
|
||||||
R"(Variable{
|
R"(Variable{
|
||||||
Decorations{
|
Decorations{
|
||||||
GroupDecoration{2}
|
GroupDecoration{2}
|
||||||
BindingDecoration{1}
|
BindingDecoration{1}
|
||||||
@ -4280,7 +4276,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||||||
uniform_constant
|
uniform_constant
|
||||||
__depth_texture_2d
|
__depth_texture_2d
|
||||||
})",
|
})",
|
||||||
R"(VariableDeclStatement{
|
R"(VariableDeclStatement{
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_99
|
x_99
|
||||||
none
|
none
|
||||||
@ -4300,10 +4296,10 @@ INSTANTIATE_TEST_SUITE_P(
|
|||||||
}
|
}
|
||||||
})"},
|
})"},
|
||||||
|
|
||||||
// Depth Cube
|
// Depth Cube
|
||||||
{"%float Cube 1 0 0 1 Unknown",
|
{"%float Cube 1 0 0 1 Unknown",
|
||||||
"%99 = OpImageQuerySizeLod %v3int %im %i1\n",
|
"%99 = OpImageQuerySizeLod %v2int %im %i1\n",
|
||||||
R"(Variable{
|
R"(Variable{
|
||||||
Decorations{
|
Decorations{
|
||||||
GroupDecoration{2}
|
GroupDecoration{2}
|
||||||
BindingDecoration{1}
|
BindingDecoration{1}
|
||||||
@ -4312,20 +4308,23 @@ INSTANTIATE_TEST_SUITE_P(
|
|||||||
uniform_constant
|
uniform_constant
|
||||||
__depth_texture_cube
|
__depth_texture_cube
|
||||||
})",
|
})",
|
||||||
R"(VariableDeclStatement{
|
R"(VariableDeclStatement{
|
||||||
VariableConst{
|
VariableConst{
|
||||||
x_99
|
x_99
|
||||||
none
|
none
|
||||||
__vec_3__i32
|
__vec_2__i32
|
||||||
{
|
{
|
||||||
TypeConstructor[not set]{
|
TypeConstructor[not set]{
|
||||||
__vec_3__i32
|
__vec_2__i32
|
||||||
Call[not set]{
|
MemberAccessor[not set]{
|
||||||
Identifier[not set]{textureDimensions}
|
Call[not set]{
|
||||||
(
|
Identifier[not set]{textureDimensions}
|
||||||
Identifier[not set]{x_20}
|
(
|
||||||
Identifier[not set]{i1}
|
Identifier[not set]{x_20}
|
||||||
)
|
Identifier[not set]{i1}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Identifier[not set]{xy}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4406,12 +4405,15 @@ INSTANTIATE_TEST_SUITE_P(
|
|||||||
{
|
{
|
||||||
TypeConstructor[not set]{
|
TypeConstructor[not set]{
|
||||||
__vec_3__i32
|
__vec_3__i32
|
||||||
Call[not set]{
|
MemberAccessor[not set]{
|
||||||
Identifier[not set]{textureDimensions}
|
Call[not set]{
|
||||||
(
|
Identifier[not set]{textureDimensions}
|
||||||
Identifier[not set]{x_20}
|
(
|
||||||
Identifier[not set]{i1}
|
Identifier[not set]{x_20}
|
||||||
)
|
Identifier[not set]{i1}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Identifier[not set]{xy}
|
||||||
}
|
}
|
||||||
Call[not set]{
|
Call[not set]{
|
||||||
Identifier[not set]{textureNumLayers}
|
Identifier[not set]{textureNumLayers}
|
||||||
@ -4486,12 +4488,15 @@ INSTANTIATE_TEST_SUITE_P(
|
|||||||
{
|
{
|
||||||
TypeConstructor[not set]{
|
TypeConstructor[not set]{
|
||||||
__vec_3__i32
|
__vec_3__i32
|
||||||
Call[not set]{
|
MemberAccessor[not set]{
|
||||||
Identifier[not set]{textureDimensions}
|
Call[not set]{
|
||||||
(
|
Identifier[not set]{textureDimensions}
|
||||||
Identifier[not set]{x_20}
|
(
|
||||||
Identifier[not set]{i1}
|
Identifier[not set]{x_20}
|
||||||
)
|
Identifier[not set]{i1}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Identifier[not set]{xy}
|
||||||
}
|
}
|
||||||
Call[not set]{
|
Call[not set]{
|
||||||
Identifier[not set]{textureNumLayers}
|
Identifier[not set]{textureNumLayers}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user