| 316 | } |
| 317 | |
| 318 | TEST_F(DescriptorTypeTest, StorageImage) { |
| 319 | const std::string text = R"( |
| 320 | OpCapability Shader |
| 321 | %1 = OpExtInstImport "GLSL.std.450" |
| 322 | OpMemoryModel Logical GLSL450 |
| 323 | OpEntryPoint Fragment %2 "main" |
| 324 | OpExecutionMode %2 OriginUpperLeft |
| 325 | OpSource GLSL 430 |
| 326 | OpName %3 "myStorageImage" |
| 327 | OpDecorate %3 DescriptorSet 0 |
| 328 | OpDecorate %3 Binding 0 |
| 329 | %4 = OpTypeVoid |
| 330 | %5 = OpTypeFunction %4 |
| 331 | %6 = OpTypeFloat 32 |
| 332 | %7 = OpTypeImage %6 2D 0 0 0 2 R32f |
| 333 | %8 = OpTypePointer UniformConstant %7 |
| 334 | %3 = OpVariable %8 UniformConstant |
| 335 | %2 = OpFunction %4 None %5 |
| 336 | %9 = OpLabel |
| 337 | %10 = OpCopyObject %8 %3 |
| 338 | OpReturn |
| 339 | OpFunctionEnd |
| 340 | )"; |
| 341 | |
| 342 | std::unique_ptr<IRContext> context = |
| 343 | BuildModule(SPV_ENV_UNIVERSAL_1_2, nullptr, text); |
| 344 | Instruction* type = context->get_def_use_mgr()->GetDef(8); |
| 345 | EXPECT_TRUE(type->IsVulkanStorageImage()); |
| 346 | EXPECT_FALSE(type->IsVulkanSampledImage()); |
| 347 | EXPECT_FALSE(type->IsVulkanStorageTexelBuffer()); |
| 348 | EXPECT_FALSE(type->IsVulkanStorageBuffer()); |
| 349 | EXPECT_FALSE(type->IsVulkanUniformBuffer()); |
| 350 | |
| 351 | Instruction* variable = context->get_def_use_mgr()->GetDef(3); |
| 352 | EXPECT_FALSE(variable->IsReadOnlyPointer()); |
| 353 | |
| 354 | Instruction* object_copy = context->get_def_use_mgr()->GetDef(10); |
| 355 | EXPECT_FALSE(object_copy->IsReadOnlyPointer()); |
| 356 | } |
| 357 | |
| 358 | TEST_F(DescriptorTypeTest, SampledImage) { |
| 359 | const std::string text = R"( |
nothing calls this directly
no test coverage detected