diff --git a/src/writer/spirv/builder.cc b/src/writer/spirv/builder.cc index 2681e9a60f..f87eb8f1f5 100644 --- a/src/writer/spirv/builder.cc +++ b/src/writer/spirv/builder.cc @@ -2479,7 +2479,7 @@ uint32_t Builder::GenerateTypeIfNeeded(ast::type::Type* type) { bool Builder::GenerateTextureType(ast::type::TextureType* texture, const Operand& result) { uint32_t array_literal = 0u; - auto dim = texture->dim(); + const auto dim = texture->dim(); if (dim == ast::type::TextureDimension::k1dArray || dim == ast::type::TextureDimension::k2dArray || dim == ast::type::TextureDimension::kCubeArray) { @@ -2520,6 +2520,12 @@ bool Builder::GenerateTextureType(ast::type::TextureType* texture, sampled_literal = 1u; } + if (dim == ast::type::TextureDimension::kCubeArray) { + if (texture->IsSampled() || texture->IsDepth()) { + push_capability(SpvCapabilitySampledCubeArray); + } + } + uint32_t type_id = 0u; if (texture->IsDepth()) { ast::type::F32Type f32; diff --git a/src/writer/spirv/builder_type_test.cc b/src/writer/spirv/builder_type_test.cc index d7403ba3c7..f72120d5b4 100644 --- a/src/writer/spirv/builder_type_test.cc +++ b/src/writer/spirv/builder_type_test.cc @@ -665,6 +665,7 @@ TEST_F(BuilderTest_Type, DepthTexture_Generate_Cube) { EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 32 %1 = OpTypeImage %2 Cube 1 0 0 1 Unknown )"); + EXPECT_EQ(DumpInstructions(b.capabilities()), ""); } TEST_F(BuilderTest_Type, DepthTexture_Generate_CubeArray) { @@ -677,6 +678,9 @@ TEST_F(BuilderTest_Type, DepthTexture_Generate_CubeArray) { EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 32 %1 = OpTypeImage %2 Cube 1 1 0 1 Unknown +)"); + EXPECT_EQ(DumpInstructions(b.capabilities()), + R"(OpCapability SampledCubeArray )"); } @@ -825,6 +829,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_Cube) { R"(%2 = OpTypeFloat 32 %1 = OpTypeImage %2 Cube 0 0 0 1 Unknown )"); + EXPECT_EQ(DumpInstructions(b.capabilities()), ""); } TEST_F(BuilderTest_Type, SampledTexture_Generate_CubeArray) { @@ -837,6 +842,9 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_CubeArray) { EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 32 %1 = OpTypeImage %2 Cube 0 1 0 1 Unknown +)"); + EXPECT_EQ(DumpInstructions(b.capabilities()), + R"(OpCapability SampledCubeArray )"); }