| 1 |
// Copyright (c) 2018 Google LLC. |
| 2 |
// |
| 3 |
// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 |
// you may not use this file except in compliance with the License. |
| 5 |
// You may obtain a copy of the License at |
| 6 |
// |
| 7 |
// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 |
// |
| 9 |
// Unless required by applicable law or agreed to in writing, software |
| 10 |
// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 |
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 |
// See the License for the specific language governing permissions and |
| 13 |
// limitations under the License. |
| 14 |
|
| 15 |
#include <sstream> |
| 16 |
#include <string> |
| 17 |
|
| 18 |
#include "gmock/gmock.h" |
| 19 |
#include "test/unit_spirv.h" |
| 20 |
#include "test/val/val_fixtures.h" |
| 21 |
|
| 22 |
namespace spvtools { |
| 23 |
namespace val { |
| 24 |
namespace { |
| 25 |
|
| 26 |
using ::testing::HasSubstr; |
| 27 |
using ::testing::Not; |
| 28 |
|
| 29 |
using ValidateBarriers = spvtest::ValidateBase<bool>; |
| 30 |
|
| 31 |
std::string GenerateShaderCodeImpl( |
| 32 |
const std::string& body, const std::string& capabilities_and_extensions, |
| 33 |
const std::string& definitions, const std::string& execution_model, |
| 34 |
const std::string& memory_model) { |
| 35 |
std::ostringstream ss; |
| 36 |
ss << R"( |
| 37 |
OpCapability Shader |
| 38 |
)"; |
| 39 |
|
| 40 |
ss << capabilities_and_extensions; |
| 41 |
ss << memory_model << std::endl; |
| 42 |
ss << "OpEntryPoint " << execution_model << " %main \"main\"\n"; |
| 43 |
if (execution_model == "Fragment") { |
| 44 |
ss << "OpExecutionMode %main OriginUpperLeft\n"; |
| 45 |
} else if (execution_model == "Geometry") { |
| 46 |
ss << "OpExecutionMode %main InputPoints\n"; |
| 47 |
ss << "OpExecutionMode %main OutputPoints\n"; |
| 48 |
} else if (execution_model == "GLCompute") { |
| 49 |
ss << "OpExecutionMode %main LocalSize 1 1 1\n"; |
| 50 |
} |
| 51 |
|
| 52 |
ss << R"( |
| 53 |
%void = OpTypeVoid |
| 54 |
%func = OpTypeFunction %void |
| 55 |
%bool = OpTypeBool |
| 56 |
%f32 = OpTypeFloat 32 |
| 57 |
%u32 = OpTypeInt 32 0 |
| 58 |
|
| 59 |
%f32_0 = OpConstant %f32 0 |
| 60 |
%f32_1 = OpConstant %f32 1 |
| 61 |
%u32_0 = OpConstant %u32 0 |
| 62 |
%u32_1 = OpConstant %u32 1 |
| 63 |
%u32_4 = OpConstant %u32 4 |
| 64 |
)"; |
| 65 |
ss << definitions; |
| 66 |
ss << R"( |
| 67 |
%cross_device = OpConstant %u32 0 |
| 68 |
%device = OpConstant %u32 1 |
| 69 |
%workgroup = OpConstant %u32 2 |
| 70 |
%subgroup = OpConstant %u32 3 |
| 71 |
%invocation = OpConstant %u32 4 |
| 72 |
%queuefamily = OpConstant %u32 5 |
| 73 |
%shadercall = OpConstant %u32 6 |
| 74 |
|
| 75 |
%none = OpConstant %u32 0 |
| 76 |
%acquire = OpConstant %u32 2 |
| 77 |
%release = OpConstant %u32 4 |
| 78 |
%acquire_release = OpConstant %u32 8 |
| 79 |
%acquire_and_release = OpConstant %u32 6 |
| 80 |
%sequentially_consistent = OpConstant %u32 16 |
| 81 |
%acquire_release_uniform_workgroup = OpConstant %u32 328 |
| 82 |
%acquire_uniform_workgroup = OpConstant %u32 322 |
| 83 |
%release_uniform_workgroup = OpConstant %u32 324 |
| 84 |
%acquire_and_release_uniform = OpConstant %u32 70 |
| 85 |
%acquire_release_subgroup = OpConstant %u32 136 |
| 86 |
%acquire_release_workgroup = OpConstant %u32 264 |
| 87 |
%uniform = OpConstant %u32 64 |
| 88 |
%uniform_workgroup = OpConstant %u32 320 |
| 89 |
%workgroup_memory = OpConstant %u32 256 |
| 90 |
%image_memory = OpConstant %u32 2048 |
| 91 |
%uniform_image_memory = OpConstant %u32 2112 |
| 92 |
|
| 93 |
%main = OpFunction %void None %func |
| 94 |
%main_entry = OpLabel |
| 95 |
)"; |
| 96 |
|
| 97 |
ss << body; |
| 98 |
|
| 99 |
ss << R"( |
| 100 |
OpReturn |
| 101 |
OpFunctionEnd)"; |
| 102 |
|
| 103 |
return ss.str(); |
| 104 |
} |
| 105 |
|
| 106 |
std::string GenerateShaderCode( |
| 107 |
const std::string& body, |
| 108 |
const std::string& capabilities_and_extensions = "", |
| 109 |
const std::string& execution_model = "GLCompute") { |
| 110 |
const std::string int64_capability = R"( |
| 111 |
OpCapability Int64 |
| 112 |
)"; |
| 113 |
const std::string int64_declarations = R"( |
| 114 |
%u64 = OpTypeInt 64 0 |
| 115 |
%u64_0 = OpConstant %u64 0 |
| 116 |
%u64_1 = OpConstant %u64 1 |
| 117 |
)"; |
| 118 |
const std::string memory_model = "OpMemoryModel Logical GLSL450"; |
| 119 |
return GenerateShaderCodeImpl( |
| 120 |
body, int64_capability + capabilities_and_extensions, int64_declarations, |
| 121 |
execution_model, memory_model); |
| 122 |
} |
| 123 |
|
| 124 |
std::string GenerateVulkanVertexShaderCode( |
| 125 |
const std::string& body, |
| 126 |
const std::string& capabilities_and_extensions = "", |
| 127 |
const std::string& execution_model = "Vertex") { |
| 128 |
const std::string memory_model = "OpMemoryModel Logical GLSL450"; |
| 129 |
return GenerateShaderCodeImpl(body, capabilities_and_extensions, "", |
| 130 |
execution_model, memory_model); |
| 131 |
} |
| 132 |
|
| 133 |
std::string GenerateKernelCode( |
| 134 |
const std::string& body, |
| 135 |
const std::string& capabilities_and_extensions = "") { |
| 136 |
std::ostringstream ss; |
| 137 |
ss << R"( |
| 138 |
OpCapability Addresses |
| 139 |
OpCapability Kernel |
| 140 |
OpCapability Linkage |
| 141 |
OpCapability Int64 |
| 142 |
OpCapability NamedBarrier |
| 143 |
)"; |
| 144 |
|
| 145 |
ss << capabilities_and_extensions; |
| 146 |
ss << R"( |
| 147 |
OpMemoryModel Physical32 OpenCL |
| 148 |
%void = OpTypeVoid |
| 149 |
%func = OpTypeFunction %void |
| 150 |
%bool = OpTypeBool |
| 151 |
%f32 = OpTypeFloat 32 |
| 152 |
%u32 = OpTypeInt 32 0 |
| 153 |
%u64 = OpTypeInt 64 0 |
| 154 |
|
| 155 |
%f32_0 = OpConstant %f32 0 |
| 156 |
%f32_1 = OpConstant %f32 1 |
| 157 |
%f32_4 = OpConstant %f32 4 |
| 158 |
%u32_0 = OpConstant %u32 0 |
| 159 |
%u32_1 = OpConstant %u32 1 |
| 160 |
%u32_4 = OpConstant %u32 4 |
| 161 |
%u64_0 = OpConstant %u64 0 |
| 162 |
%u64_1 = OpConstant %u64 1 |
| 163 |
%u64_4 = OpConstant %u64 4 |
| 164 |
|
| 165 |
%cross_device = OpConstant %u32 0 |
| 166 |
%device = OpConstant %u32 1 |
| 167 |
%workgroup = OpConstant %u32 2 |
| 168 |
%subgroup = OpConstant %u32 3 |
| 169 |
%invocation = OpConstant %u32 4 |
| 170 |
|
| 171 |
%none = OpConstant %u32 0 |
| 172 |
%acquire = OpConstant %u32 2 |
| 173 |
%release = OpConstant %u32 4 |
| 174 |
%acquire_release = OpConstant %u32 8 |
| 175 |
%acquire_and_release = OpConstant %u32 6 |
| 176 |
%sequentially_consistent = OpConstant %u32 16 |
| 177 |
%acquire_release_workgroup = OpConstant %u32 264 |
| 178 |
|
| 179 |
%named_barrier = OpTypeNamedBarrier |
| 180 |
|
| 181 |
%main = OpFunction %void None %func |
| 182 |
%main_entry = OpLabel |
| 183 |
)"; |
| 184 |
|
| 185 |
ss << body; |
| 186 |
|
| 187 |
ss << R"( |
| 188 |
OpReturn |
| 189 |
OpFunctionEnd)"; |
| 190 |
|
| 191 |
return ss.str(); |
| 192 |
} |
| 193 |
|
| 194 |
TEST_F(ValidateBarriers, OpControlBarrierGLComputeSuccess) { |
| 195 |
const std::string body = R"( |
| 196 |
OpControlBarrier %device %device %none |
| 197 |
OpControlBarrier %workgroup %workgroup %acquire |
| 198 |
OpControlBarrier %workgroup %device %release |
| 199 |
OpControlBarrier %cross_device %cross_device %acquire_release |
| 200 |
OpControlBarrier %cross_device %cross_device %sequentially_consistent |
| 201 |
OpControlBarrier %cross_device %cross_device %acquire_release_uniform_workgroup |
| 202 |
)"; |
| 203 |
|
| 204 |
CompileSuccessfully(GenerateShaderCode(body)); |
| 205 |
ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); |
| 206 |
} |
| 207 |
|
| 208 |
TEST_F(ValidateBarriers, OpControlBarrierKernelSuccess) { |
| 209 |
const std::string body = R"( |
| 210 |
OpControlBarrier %device %device %none |
| 211 |
OpControlBarrier %workgroup %workgroup %acquire |
| 212 |
OpControlBarrier %workgroup %device %release |
| 213 |
OpControlBarrier %cross_device %cross_device %acquire_release |
| 214 |
OpControlBarrier %cross_device %cross_device %sequentially_consistent |
| 215 |
OpControlBarrier %cross_device %cross_device %acquire_release_workgroup |
| 216 |
)"; |
| 217 |
|
| 218 |
CompileSuccessfully(GenerateKernelCode(body), SPV_ENV_UNIVERSAL_1_1); |
| 219 |
ASSERT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_UNIVERSAL_1_1)); |
| 220 |
} |
| 221 |
|
| 222 |
TEST_F(ValidateBarriers, OpControlBarrierTesselationControlSuccess) { |
| 223 |
const std::string body = R"( |
| 224 |
OpControlBarrier %device %device %none |
| 225 |
OpControlBarrier %workgroup %workgroup %acquire |
| 226 |
OpControlBarrier %workgroup %device %release |
| 227 |
OpControlBarrier %cross_device %cross_device %acquire_release |
| 228 |
OpControlBarrier %cross_device %cross_device %sequentially_consistent |
| 229 |
OpControlBarrier %cross_device %cross_device %acquire_release_uniform_workgroup |
| 230 |
)"; |
| 231 |
|
| 232 |
CompileSuccessfully(GenerateShaderCode(body, "OpCapability Tessellation\n", |
| 233 |
"TessellationControl")); |
| 234 |
ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); |
| 235 |
} |
| 236 |
|
| 237 |
TEST_F(ValidateBarriers, OpControlBarrierVulkanSuccess) { |
| 238 |
const std::string body = R"( |
| 239 |
OpControlBarrier %workgroup %device %none |
| 240 |
OpControlBarrier %workgroup %workgroup %acquire_release_uniform_workgroup |
| 241 |
)"; |
| 242 |
|
| 243 |
CompileSuccessfully(GenerateShaderCode(body), SPV_ENV_VULKAN_1_0); |
| 244 |
ASSERT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_0)); |
| 245 |
} |
| 246 |
|
| 247 |
TEST_F(ValidateBarriers, OpControlBarrierExecutionModelFragmentSpirv12) { |
| 248 |
const std::string body = R"( |
| 249 |
OpControlBarrier %device %device %none |
| 250 |
)"; |
| 251 |
|
| 252 |
CompileSuccessfully(GenerateShaderCode(body, "", "Fragment"), |
| 253 |
SPV_ENV_UNIVERSAL_1_2); |
| 254 |
ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_UNIVERSAL_1_2)); |
| 255 |
EXPECT_THAT( |
| 256 |
getDiagnosticString(), |
| 257 |
HasSubstr("OpControlBarrier requires one of the following " |
| 258 |
"Execution Models: TessellationControl, GLCompute, Kernel, " |
| 259 |
"MeshNV or TaskNV")); |
| 260 |
} |
| 261 |
|
| 262 |
TEST_F(ValidateBarriers, OpControlBarrierExecutionModelFragmentSpirv13) { |
| 263 |
const std::string body = R"( |
| 264 |
OpControlBarrier %device %device %none |
| 265 |
)"; |
| 266 |
|
| 267 |
CompileSuccessfully(GenerateShaderCode(body, "", "Fragment"), |
| 268 |
SPV_ENV_UNIVERSAL_1_3); |
| 269 |
ASSERT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_UNIVERSAL_1_3)); |
| 270 |
} |
| 271 |
|
| 272 |
TEST_F(ValidateBarriers, OpControlBarrierFloatExecutionScope) { |
| 273 |
const std::string body = R"( |
| 274 |
OpControlBarrier %f32_1 %device %none |
| 275 |
)"; |
| 276 |
|
| 277 |
CompileSuccessfully(GenerateShaderCode(body)); |
| 278 |
ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); |
| 279 |
EXPECT_THAT(getDiagnosticString(), |
| 280 |
HasSubstr("ControlBarrier: expected scope to be a 32-bit int")); |
| 281 |
} |
| 282 |
|
| 283 |
TEST_F(ValidateBarriers, OpControlBarrierU64ExecutionScope) { |
| 284 |
const std::string body = R"( |
| 285 |
OpControlBarrier %u64_1 %device %none |
| 286 |
)"; |
| 287 |
|
| 288 |
CompileSuccessfully(GenerateShaderCode(body)); |
| 289 |
ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); |
| 290 |
EXPECT_THAT(getDiagnosticString(), |
| 291 |
HasSubstr("ControlBarrier: expected scope to be a 32-bit int")); |
| 292 |
} |
| 293 |
|
| 294 |
TEST_F(ValidateBarriers, OpControlBarrierFloatMemoryScope) { |
| 295 |
const std::string body = R"( |
| 296 |
OpControlBarrier %device %f32_1 %none |
| 297 |
)"; |
| 298 |
|
| 299 |
CompileSuccessfully(GenerateShaderCode(body)); |
| 300 |
ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); |
| 301 |
EXPECT_THAT(getDiagnosticString(), |
| 302 |
HasSubstr("ControlBarrier: expected scope to be a 32-bit int")); |
| 303 |
} |
| 304 |
|
| 305 |
TEST_F(ValidateBarriers, OpControlBarrierU64MemoryScope) { |
| 306 |
const std::string body = R"( |
| 307 |
OpControlBarrier %device %u64_1 %none |
| 308 |
)"; |
| 309 |
|
| 310 |
CompileSuccessfully(GenerateShaderCode(body)); |
| 311 |
ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); |
| 312 |
EXPECT_THAT(getDiagnosticString(), |
| 313 |
HasSubstr("ControlBarrier: expected scope to be a 32-bit int")); |
| 314 |
} |
| 315 |
|
| 316 |
TEST_F(ValidateBarriers, OpControlBarrierFloatMemorySemantics) { |
| 317 |
const std::string body = R"( |
| 318 |
OpControlBarrier %device %device %f32_0 |
| 319 |
)"; |
| 320 |
|
| 321 |
CompileSuccessfully(GenerateShaderCode(body)); |
| 322 |
ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); |
| 323 |
EXPECT_THAT( |
| 324 |
getDiagnosticString(), |
| 325 |
HasSubstr( |
| 326 |
"ControlBarrier: expected Memory Semantics to be a 32-bit int")); |
| 327 |
} |
| 328 |
|
| 329 |
TEST_F(ValidateBarriers, OpControlBarrierU64MemorySemantics) { |
| 330 |
const std::string body = R"( |
| 331 |
OpControlBarrier %device %device %u64_0 |
| 332 |
)"; |
| 333 |
|
| 334 |
CompileSuccessfully(GenerateShaderCode(body)); |
| 335 |
ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); |
| 336 |
EXPECT_THAT( |
| 337 |
getDiagnosticString(), |
| 338 |
HasSubstr( |
| 339 |
"ControlBarrier: expected Memory Semantics to be a 32-bit int")); |
| 340 |
} |
| 341 |
|
| 342 |
TEST_F(ValidateBarriers, OpControlBarrierVulkanExecutionScopeDevice) { |
| 343 |
const std::string body = R"( |
| 344 |
OpControlBarrier %device %workgroup %none |
| 345 |
)"; |
| 346 |
|
| 347 |
CompileSuccessfully(GenerateShaderCode(body), SPV_ENV_VULKAN_1_0); |
| 348 |
ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_0)); |
| 349 |
EXPECT_THAT(getDiagnosticString(), |
| 350 |
AnyVUID("VUID-StandaloneSpirv-None-04636")); |
| 351 |
EXPECT_THAT(getDiagnosticString(), |
| 352 |
HasSubstr("ControlBarrier: in Vulkan environment Execution Scope " |
| 353 |
"is limited to Workgroup and Subgroup")); |
| 354 |
} |
| 355 |
|
| 356 |
TEST_F(ValidateBarriers, OpControlBarrierVulkanMemoryScopeSubgroup) { |
| 357 |
const std::string body = R"( |
| 358 |
OpControlBarrier %subgroup %subgroup %none |
| 359 |
)"; |
| 360 |
|
| 361 |
CompileSuccessfully(GenerateShaderCode(body), SPV_ENV_VULKAN_1_0); |
| 362 |
ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_0)); |
| 363 |
EXPECT_THAT(getDiagnosticString(), |
| 364 |
AnyVUID("VUID-StandaloneSpirv-SubgroupVoteKHR-07951")); |
| 365 |
EXPECT_THAT( |
| 366 |
getDiagnosticString(), |
| 367 |
HasSubstr( |
| 368 |
"ControlBarrier: in Vulkan 1.0 environment Memory Scope is can not " |
| 369 |
"be Subgroup without SubgroupBallotKHR or SubgroupVoteKHR declared")); |
| 370 |
} |
| 371 |
|
| 372 |
TEST_F(ValidateBarriers, OpControlBarrierVulkanMemoryScopeSubgroupVoteKHR) { |
| 373 |
const std::string capabilities = R"( |
| 374 |
OpCapability SubgroupVoteKHR |
| 375 |
OpExtension "SPV_KHR_subgroup_vote" |
| 376 |
)"; |
| 377 |
const std::string body = R"( |
| 378 |
OpControlBarrier %subgroup %subgroup %none |
| 379 |
)"; |
| 380 |
|
| 381 |
CompileSuccessfully(GenerateShaderCode(body, capabilities), |
| 382 |
SPV_ENV_VULKAN_1_0); |
| 383 |
ASSERT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_0)); |
| 384 |
} |
| 385 |
|
| 386 |
TEST_F(ValidateBarriers, OpControlBarrierVulkan1p1MemoryScopeSubgroup) { |
| 387 |
const std::string body = R"( |
| 388 |
OpControlBarrier %subgroup %subgroup %none |
| 389 |
)"; |
| 390 |
|
| 391 |
CompileSuccessfully(GenerateShaderCode(body), SPV_ENV_VULKAN_1_1); |
| 392 |
ASSERT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_1)); |
| 393 |
} |
| 394 |
|
| 395 |
TEST_F(ValidateBarriers, OpControlBarrierVulkan1p1MemoryScopeCrossDevice) { |
| 396 |
const std::string body = R"( |
| 397 |
OpControlBarrier %subgroup %cross_device %none |
| 398 |
)"; |
| 399 |
|
| 400 |
CompileSuccessfully(GenerateShaderCode(body), SPV_ENV_VULKAN_1_1); |
| 401 |
ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_1)); |
| 402 |
EXPECT_THAT(getDiagnosticString(), |
| 403 |
AnyVUID("VUID-StandaloneSpirv-None-04638")); |
| 404 |
EXPECT_THAT(getDiagnosticString(), |
| 405 |
HasSubstr("ControlBarrier: in Vulkan environment Memory Scope is " |
| 406 |
"limited to Device, QueueFamily, Workgroup, " |
| 407 |
"ShaderCallKHR, Subgroup, or Invocation")); |
| 408 |
} |
| 409 |
|
| 410 |
TEST_F(ValidateBarriers, |
| 411 |
OpControlBarrierVulkan1p1WorkgroupNonComputeMemoryFailure) { |
| 412 |
const std::string body = R"( |
| 413 |
OpControlBarrier %subgroup %workgroup %acquire_release_workgroup |
| 414 |
)"; |
| 415 |
|
| 416 |
CompileSuccessfully(GenerateVulkanVertexShaderCode(body), SPV_ENV_VULKAN_1_1); |
| 417 |
EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_1)); |
| 418 |
EXPECT_THAT(getDiagnosticString(), |
| 419 |
AnyVUID("VUID-StandaloneSpirv-None-07321")); |
| 420 |
EXPECT_THAT( |
| 421 |
getDiagnosticString(), |
| 422 |
HasSubstr("Workgroup Memory Scope is limited to MeshNV, " |
| 423 |
"TaskNV, MeshEXT, TaskEXT, TessellationControl, and GLCompute " |
| 424 |
"execution model")); |
| 425 |
} |
| 426 |
|
| 427 |
TEST_F(ValidateBarriers, |
| 428 |
OpControlBarrierVulkan1p1WorkgroupNonComputeExecutionFailure) { |
| 429 |
const std::string body = R"( |
| 430 |
OpControlBarrier %workgroup %subgroup %acquire_release_workgroup |
| 431 |
)"; |
| 432 |
|
| 433 |
CompileSuccessfully(GenerateVulkanVertexShaderCode(body), SPV_ENV_VULKAN_1_1); |
| 434 |
EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_1)); |
| 435 |
EXPECT_THAT(getDiagnosticString(), |
| 436 |
AnyVUID("VUID-StandaloneSpirv-None-04637")); |
| 437 |
EXPECT_THAT(getDiagnosticString(), |
| 438 |
HasSubstr("in Vulkan environment, Workgroup execution scope is " |
| 439 |
"only for TaskNV, MeshNV, TaskEXT, MeshEXT, " |
| 440 |
"TessellationControl, and GLCompute execution models")); |
| 441 |
} |
| 442 |
|
| 443 |
TEST_F(ValidateBarriers, OpControlBarrierVulkan1p1WorkgroupComputeSuccess) { |
| 444 |
const std::string body = R"( |
| 445 |
OpControlBarrier %workgroup %workgroup %acquire_uniform_workgroup |
| 446 |
)"; |
| 447 |
|
| 448 |
CompileSuccessfully(GenerateShaderCode(body), SPV_ENV_VULKAN_1_1); |
| 449 |
ASSERT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_1)); |
| 450 |
} |
| 451 |
|
| 452 |
TEST_F(ValidateBarriers, OpControlBarrierVulkan1p1WorkgroupNonComputeSuccess) { |
| 453 |
const std::string body = R"( |
| 454 |
OpControlBarrier %subgroup %subgroup %acquire_uniform_workgroup |
| 455 |
)"; |
| 456 |
|
| 457 |
CompileSuccessfully(GenerateVulkanVertexShaderCode(body), SPV_ENV_VULKAN_1_1); |
| 458 |
ASSERT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_1)); |
| 459 |
} |
| 460 |
|
| 461 |
TEST_F(ValidateBarriers, OpControlBarrierVulkanInvocationSuccess) { |
| 462 |
const std::string body = R"( |
| 463 |
OpControlBarrier %workgroup %invocation %none |
| 464 |
)"; |
| 465 |
|
| 466 |
CompileSuccessfully(GenerateShaderCode(body), SPV_ENV_VULKAN_1_0); |
| 467 |
ASSERT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_0)); |
| 468 |
} |
| 469 |
|
| 470 |
TEST_F(ValidateBarriers, OpControlBarrierVulkanInvocationFailure) { |
| 471 |
const std::string body = R"( |
| 472 |
OpControlBarrier %workgroup %invocation %acquire_uniform_workgroup |
| 473 |
)"; |
| 474 |
|
| 475 |
CompileSuccessfully(GenerateShaderCode(body), SPV_ENV_VULKAN_1_0); |
| 476 |
EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_0)); |
| 477 |
EXPECT_THAT(getDiagnosticString(), |
| 478 |
AnyVUID("VUID-StandaloneSpirv-None-04641")); |
| 479 |
EXPECT_THAT( |
| 480 |
getDiagnosticString(), |
| 481 |
HasSubstr( |
| 482 |
"ControlBarrier: Vulkan specification requires Memory " |
| 483 |
"Semantics to be Relaxed if used with Invocation Memory Scope")); |
| 484 |
} |
| 485 |
|
| 486 |
TEST_F(ValidateBarriers, OpControlBarrierAcquireAndRelease) { |
| 487 |
const std::string body = R"( |
| 488 |
OpControlBarrier %device %device %acquire_and_release_uniform |
| 489 |
)"; |
| 490 |
|
| 491 |
CompileSuccessfully(GenerateShaderCode(body)); |
| 492 |
ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); |
| 493 |
EXPECT_THAT(getDiagnosticString(), |
| 494 |
HasSubstr("ControlBarrier: Memory Semantics must have at most " |
| 495 |
"one non-relaxed memory order bit set")); |
| 496 |
} |
| 497 |
|
| 498 |
TEST_F(ValidateBarriers, OpControlBarrierSubgroupExecutionFragment1p1) { |
| 499 |
const std::string body = R"( |
| 500 |
OpControlBarrier %subgroup %subgroup %acquire_release_workgroup |
| 501 |
)"; |
| 502 |
|
| 503 |
CompileSuccessfully(GenerateShaderCode(body, "", "Fragment"), |
| 504 |
SPV_ENV_VULKAN_1_1); |
| 505 |
ASSERT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_1)); |
| 506 |
} |
| 507 |
|
| 508 |
TEST_F(ValidateBarriers, OpControlBarrierWorkgroupExecutionFragment1p1) { |
| 509 |
const std::string body = R"( |
| 510 |
OpControlBarrier %workgroup %workgroup %acquire_release_workgroup |
| 511 |
)"; |
| 512 |
|
| 513 |
CompileSuccessfully(GenerateShaderCode(body, "", "Fragment"), |
| 514 |
SPV_ENV_VULKAN_1_1); |
| 515 |
ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_1)); |
| 516 |
EXPECT_THAT(getDiagnosticString(), |
| 517 |
AnyVUID("VUID-StandaloneSpirv-OpControlBarrier-04682")); |
| 518 |
EXPECT_THAT( |
| 519 |
getDiagnosticString(), |
| 520 |
HasSubstr( |
| 521 |
"OpControlBarrier execution scope must be Subgroup for Fragment, " |
| 522 |
"Vertex, Geometry, TessellationEvaluation, RayGeneration, " |
| 523 |
"Intersection, AnyHit, ClosestHit, and Miss execution models")); |
| 524 |
} |
| 525 |
|
| 526 |
TEST_F(ValidateBarriers, OpControlBarrierSubgroupExecutionFragment1p0) { |
| 527 |
const std::string body = R"( |
| 528 |
OpControlBarrier %subgroup %workgroup %acquire_release_workgroup |
| 529 |
)"; |
| 530 |
|
| 531 |
CompileSuccessfully(GenerateShaderCode(body, "", "Fragment"), |
| 532 |
SPV_ENV_VULKAN_1_0); |
| 533 |
ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_0)); |
| 534 |
EXPECT_THAT(getDiagnosticString(), |
| 535 |
HasSubstr("OpControlBarrier requires one of the following " |
| 536 |
"Execution " |
| 537 |
"Models: TessellationControl, GLCompute, Kernel, " |
| 538 |
"MeshNV or TaskNV")); |
| 539 |
} |
| 540 |
|
| 541 |
TEST_F(ValidateBarriers, OpControlBarrierSubgroupExecutionVertex1p1) { |
| 542 |
const std::string body = R"( |
| 543 |
OpControlBarrier %subgroup %subgroup %acquire_release_workgroup |
| 544 |
)"; |
| 545 |
|
| 546 |
CompileSuccessfully(GenerateShaderCode(body, "", "Vertex"), |
| 547 |
SPV_ENV_VULKAN_1_1); |
| 548 |
ASSERT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_1)); |
| 549 |
} |
| 550 |
|
| 551 |
TEST_F(ValidateBarriers, OpControlBarrierWorkgroupExecutionVertex1p1) { |
| 552 |
const std::string body = R"( |
| 553 |
OpControlBarrier %workgroup %workgroup %acquire_release_workgroup |
| 554 |
)"; |
| 555 |
|
| 556 |
CompileSuccessfully(GenerateShaderCode(body, "", "Vertex"), |
| 557 |
SPV_ENV_VULKAN_1_1); |
| 558 |
ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_1)); |
| 559 |
EXPECT_THAT(getDiagnosticString(), |
| 560 |
AnyVUID("VUID-StandaloneSpirv-OpControlBarrier-04682")); |
| 561 |
EXPECT_THAT( |
| 562 |
getDiagnosticString(), |
| 563 |
HasSubstr( |
| 564 |
"OpControlBarrier execution scope must be Subgroup for Fragment, " |
| 565 |
"Vertex, Geometry, TessellationEvaluation, RayGeneration, " |
| 566 |
"Intersection, AnyHit, ClosestHit, and Miss execution models")); |
| 567 |
} |
| 568 |
|
| 569 |
TEST_F(ValidateBarriers, OpControlBarrierSubgroupExecutionVertex1p0) { |
| 570 |
const std::string body = R"( |
| 571 |
OpControlBarrier %subgroup %workgroup %acquire_release_workgroup |
| 572 |
)"; |
| 573 |
|
| 574 |
CompileSuccessfully(GenerateShaderCode(body, "", "Vertex"), |
| 575 |
SPV_ENV_VULKAN_1_0); |
| 576 |
ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_0)); |
| 577 |
EXPECT_THAT( |
| 578 |
getDiagnosticString(), |
| 579 |
HasSubstr("OpControlBarrier requires one of the following " |
| 580 |
"Execution Models: TessellationControl, GLCompute, Kernel, " |
| 581 |
"MeshNV or TaskNV")); |
| 582 |
} |
| 583 |
|
| 584 |
TEST_F(ValidateBarriers, OpControlBarrierSubgroupExecutionGeometry1p1) { |
| 585 |
const std::string body = R"( |
| 586 |
OpControlBarrier %subgroup %subgroup %acquire_release_workgroup |
| 587 |
)"; |
| 588 |
|
| 589 |
CompileSuccessfully( |
| 590 |
GenerateShaderCode(body, "OpCapability Geometry\n", "Geometry"), |
| 591 |
SPV_ENV_VULKAN_1_1); |
| 592 |
ASSERT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_1)); |
| 593 |
} |
| 594 |
|
| 595 |
TEST_F(ValidateBarriers, OpControlBarrierWorkgroupExecutionGeometry1p1) { |
| 596 |
const std::string body = R"( |
| 597 |
OpControlBarrier %workgroup %workgroup %acquire_release_workgroup |
| 598 |
)"; |
| 599 |
|
| 600 |
CompileSuccessfully( |
| 601 |
GenerateShaderCode(body, "OpCapability Geometry\n", "Geometry"), |
| 602 |
SPV_ENV_VULKAN_1_1); |
| 603 |
ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_1)); |
| 604 |
EXPECT_THAT(getDiagnosticString(), |
| 605 |
AnyVUID("VUID-StandaloneSpirv-OpControlBarrier-04682")); |
| 606 |
EXPECT_THAT( |
| 607 |
getDiagnosticString(), |
| 608 |
HasSubstr( |
| 609 |
"OpControlBarrier execution scope must be Subgroup for Fragment, " |
| 610 |
"Vertex, Geometry, TessellationEvaluation, RayGeneration, " |
| 611 |
"Intersection, AnyHit, ClosestHit, and Miss execution models")); |
| 612 |
} |
| 613 |
|
| 614 |
TEST_F(ValidateBarriers, OpControlBarrierSubgroupExecutionGeometry1p0) { |
| 615 |
const std::string body = R"( |
| 616 |
OpControlBarrier %subgroup %workgroup %acquire_release_workgroup |
| 617 |
)"; |
| 618 |
|
| 619 |
CompileSuccessfully( |
| 620 |
GenerateShaderCode(body, "OpCapability Geometry\n", "Geometry"), |
| 621 |
SPV_ENV_VULKAN_1_0); |
| 622 |
ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_0)); |
| 623 |
EXPECT_THAT(getDiagnosticString(), |
| 624 |
HasSubstr("OpControlBarrier requires one of the following " |
| 625 |
"Execution " |
| 626 |
"Models: TessellationControl, GLCompute, Kernel, " |
| 627 |
"MeshNV or TaskNV")); |
| 628 |
} |
| 629 |
|
| 630 |
TEST_F(ValidateBarriers, |
| 631 |
OpControlBarrierSubgroupExecutionTessellationEvaluation1p1) { |
| 632 |
const std::string body = R"( |
| 633 |
OpControlBarrier %subgroup %subgroup %acquire_release_workgroup |
| 634 |
)"; |
| 635 |
|
| 636 |
CompileSuccessfully(GenerateShaderCode(body, "OpCapability Tessellation\n", |
| 637 |
"TessellationEvaluation"), |
| 638 |
SPV_ENV_VULKAN_1_1); |
| 639 |
ASSERT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_1)); |
| 640 |
} |
| 641 |
|
| 642 |
TEST_F(ValidateBarriers, |
| 643 |
OpControlBarrierWorkgroupExecutionTessellationEvaluation1p1) { |
| 644 |
const std::string body = R"( |
| 645 |
OpControlBarrier %workgroup %workgroup %acquire_release_workgroup |
| 646 |
)"; |
| 647 |
|
| 648 |
CompileSuccessfully(GenerateShaderCode(body, "OpCapability Tessellation\n", |
| 649 |
"TessellationEvaluation"), |
| 650 |
SPV_ENV_VULKAN_1_1); |
| 651 |
ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_1)); |
| 652 |
EXPECT_THAT(getDiagnosticString(), |
| 653 |
AnyVUID("VUID-StandaloneSpirv-OpControlBarrier-04682")); |
| 654 |
EXPECT_THAT( |
| 655 |
getDiagnosticString(), |
| 656 |
HasSubstr( |
| 657 |
"OpControlBarrier execution scope must be Subgroup for Fragment, " |
| 658 |
"Vertex, Geometry, TessellationEvaluation, RayGeneration, " |
| 659 |
"Intersection, AnyHit, ClosestHit, and Miss execution models")); |
| 660 |
} |
| 661 |
|
| 662 |
TEST_F(ValidateBarriers, |
| 663 |
OpControlBarrierSubgroupExecutionTessellationEvaluation1p0) { |
| 664 |
const std::string body = R"( |
| 665 |
OpControlBarrier %subgroup %workgroup %acquire_release_workgroup |
| 666 |
)"; |
| 667 |
|
| 668 |
CompileSuccessfully(GenerateShaderCode(body, "OpCapability Tessellation\n", |
| 669 |
"TessellationEvaluation"), |
| 670 |
SPV_ENV_VULKAN_1_0); |
| 671 |
ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_0)); |
| 672 |
EXPECT_THAT(getDiagnosticString(), |
| 673 |
HasSubstr("OpControlBarrier requires one of the following " |
| 674 |
"Execution Models: TessellationControl, GLCompute, " |
| 675 |
"Kernel, MeshNV or TaskNV")); |
| 676 |
} |
| 677 |
|
| 678 |
TEST_F(ValidateBarriers, OpMemoryBarrierSuccess) { |
| 679 |
const std::string body = R"( |
| 680 |
OpMemoryBarrier %cross_device %acquire_release_uniform_workgroup |
| 681 |
OpMemoryBarrier %device %uniform |
| 682 |
)"; |
| 683 |
|
| 684 |
CompileSuccessfully(GenerateShaderCode(body)); |
| 685 |
ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); |
| 686 |
} |
| 687 |
|
| 688 |
TEST_F(ValidateBarriers, OpMemoryBarrierKernelSuccess) { |
| 689 |
const std::string body = R"( |
| 690 |
OpMemoryBarrier %cross_device %acquire_release_workgroup |
| 691 |
OpMemoryBarrier %device %none |
| 692 |
)"; |
| 693 |
|
| 694 |
CompileSuccessfully(GenerateKernelCode(body), SPV_ENV_UNIVERSAL_1_1); |
| 695 |
ASSERT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_UNIVERSAL_1_1)); |
| 696 |
} |
| 697 |
|
| 698 |
TEST_F(ValidateBarriers, OpMemoryBarrierVulkanSuccess) { |
| 699 |
const std::string body = R"( |
| 700 |
OpMemoryBarrier %workgroup %acquire_release_uniform_workgroup |
| 701 |
)"; |
| 702 |
|
| 703 |
CompileSuccessfully(GenerateShaderCode(body), SPV_ENV_VULKAN_1_0); |
| 704 |
ASSERT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_0)); |
| 705 |
} |
| 706 |
|
| 707 |
TEST_F(ValidateBarriers, OpMemoryBarrierFloatMemoryScope) { |
| 708 |
const std::string body = R"( |
| 709 |
OpMemoryBarrier %f32_1 %acquire_release_uniform_workgroup |
| 710 |
)"; |
| 711 |
|
| 712 |
CompileSuccessfully(GenerateShaderCode(body)); |
| 713 |
ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); |
| 714 |
EXPECT_THAT(getDiagnosticString(), |
| 715 |
HasSubstr("MemoryBarrier: expected scope to be a 32-bit int")); |
| 716 |
} |
| 717 |
|
| 718 |
TEST_F(ValidateBarriers, OpMemoryBarrierU64MemoryScope) { |
| 719 |
const std::string body = R"( |
| 720 |
OpMemoryBarrier %u64_1 %acquire_release_uniform_workgroup |
| 721 |
)"; |
| 722 |
|
| 723 |
CompileSuccessfully(GenerateShaderCode(body)); |
| 724 |
ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); |
| 725 |
EXPECT_THAT(getDiagnosticString(), |
| 726 |
HasSubstr("MemoryBarrier: expected scope to be a 32-bit int")); |
| 727 |
} |
| 728 |
|
| 729 |
TEST_F(ValidateBarriers, OpMemoryBarrierFloatMemorySemantics) { |
| 730 |
const std::string body = R"( |
| 731 |
OpMemoryBarrier %device %f32_0 |
| 732 |
)"; |
| 733 |
|
| 734 |
CompileSuccessfully(GenerateShaderCode(body)); |
| 735 |
ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); |
| 736 |
EXPECT_THAT( |
| 737 |
getDiagnosticString(), |
| 738 |
HasSubstr("MemoryBarrier: expected Memory Semantics to be a 32-bit int")); |
| 739 |
} |
| 740 |
|
| 741 |
TEST_F(ValidateBarriers, OpMemoryBarrierU64MemorySemantics) { |
| 742 |
const std::string body = R"( |
| 743 |
OpMemoryBarrier %device %u64_0 |
| 744 |
)"; |
| 745 |
|
| 746 |
CompileSuccessfully(GenerateShaderCode(body)); |
| 747 |
ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); |
| 748 |
EXPECT_THAT( |
| 749 |
getDiagnosticString(), |
| 750 |
HasSubstr("MemoryBarrier: expected Memory Semantics to be a 32-bit int")); |
| 751 |
} |
| 752 |
|
| 753 |
TEST_F(ValidateBarriers, OpMemoryBarrierVulkanMemoryScopeSubgroup) { |
| 754 |
const std::string body = R"( |
| 755 |
OpMemoryBarrier %subgroup %acquire_release_uniform_workgroup |
| 756 |
)"; |
| 757 |
|
| 758 |
CompileSuccessfully(GenerateShaderCode(body), SPV_ENV_VULKAN_1_0); |
| 759 |
ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_0)); |
| 760 |
EXPECT_THAT(getDiagnosticString(), |
| 761 |
AnyVUID("VUID-StandaloneSpirv-SubgroupVoteKHR-07951")); |
| 762 |
EXPECT_THAT( |
| 763 |
getDiagnosticString(), |
| 764 |
HasSubstr( |
| 765 |
"MemoryBarrier: in Vulkan 1.0 environment Memory Scope is can not be " |
| 766 |
"Subgroup without SubgroupBallotKHR or SubgroupVoteKHR declared")); |
| 767 |
} |
| 768 |
|
| 769 |
TEST_F(ValidateBarriers, OpMemoryBarrierVulkan1p1MemoryScopeSubgroup) { |
| 770 |
const std::string body = R"( |
| 771 |
OpMemoryBarrier %subgroup %acquire_release_uniform_workgroup |
| 772 |
)"; |
| 773 |
|
| 774 |
CompileSuccessfully(GenerateShaderCode(body), SPV_ENV_VULKAN_1_1); |
| 775 |
ASSERT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_1)); |
| 776 |
} |
| 777 |
|
| 778 |
TEST_F(ValidateBarriers, OpMemoryBarrierAcquireAndRelease) { |
| 779 |
const std::string body = R"( |
| 780 |
OpMemoryBarrier %device %acquire_and_release_uniform |
| 781 |
)"; |
| 782 |
|
| 783 |
CompileSuccessfully(GenerateShaderCode(body)); |
| 784 |
ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); |
| 785 |
EXPECT_THAT(getDiagnosticString(), |
| 786 |
HasSubstr("MemoryBarrier: Memory Semantics must have at most one " |
| 787 |
"non-relaxed memory order bit set")); |
| 788 |
} |
| 789 |
|
| 790 |
TEST_F(ValidateBarriers, OpNamedBarrierInitializeSuccess) { |
| 791 |
const std::string body = R"( |
| 792 |
%barrier = OpNamedBarrierInitialize %named_barrier %u32_4 |
| 793 |
)"; |
| 794 |
|
| 795 |
CompileSuccessfully(GenerateKernelCode(body), SPV_ENV_UNIVERSAL_1_1); |
| 796 |
ASSERT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_UNIVERSAL_1_1)); |
| 797 |
} |
| 798 |
|
| 799 |
TEST_F(ValidateBarriers, OpNamedBarrierInitializeWrongResultType) { |
| 800 |
const std::string body = R"( |
| 801 |
%barrier = OpNamedBarrierInitialize %u32 %u32_4 |
| 802 |
)"; |
| 803 |
|
| 804 |
CompileSuccessfully(GenerateKernelCode(body), SPV_ENV_UNIVERSAL_1_1); |
| 805 |
ASSERT_EQ(SPV_ERROR_INVALID_DATA, |
| 806 |
ValidateInstructions(SPV_ENV_UNIVERSAL_1_1)); |
| 807 |
EXPECT_THAT(getDiagnosticString(), |
| 808 |
HasSubstr("NamedBarrierInitialize: expected Result Type to be " |
| 809 |
"OpTypeNamedBarrier")); |
| 810 |
} |
| 811 |
|
| 812 |
TEST_F(ValidateBarriers, OpNamedBarrierInitializeFloatSubgroupCount) { |
| 813 |
const std::string body = R"( |
| 814 |
%barrier = OpNamedBarrierInitialize %named_barrier %f32_4 |
| 815 |
)"; |
| 816 |
|
| 817 |
CompileSuccessfully(GenerateKernelCode(body), SPV_ENV_UNIVERSAL_1_1); |
| 818 |
ASSERT_EQ(SPV_ERROR_INVALID_DATA, |
| 819 |
ValidateInstructions(SPV_ENV_UNIVERSAL_1_1)); |
| 820 |
EXPECT_THAT(getDiagnosticString(), |
| 821 |
HasSubstr("NamedBarrierInitialize: expected Subgroup Count to be " |
| 822 |
"a 32-bit int")); |
| 823 |
} |
| 824 |
|
| 825 |
TEST_F(ValidateBarriers, OpNamedBarrierInitializeU64SubgroupCount) { |
| 826 |
const std::string body = R"( |
| 827 |
%barrier = OpNamedBarrierInitialize %named_barrier %u64_4 |
| 828 |
)"; |
| 829 |
|
| 830 |
CompileSuccessfully(GenerateKernelCode(body), SPV_ENV_UNIVERSAL_1_1); |
| 831 |
ASSERT_EQ(SPV_ERROR_INVALID_DATA, |
| 832 |
ValidateInstructions(SPV_ENV_UNIVERSAL_1_1)); |
| 833 |
EXPECT_THAT(getDiagnosticString(), |
| 834 |
HasSubstr("NamedBarrierInitialize: expected Subgroup Count to be " |
| 835 |
"a 32-bit int")); |
| 836 |
} |
| 837 |
|
| 838 |
TEST_F(ValidateBarriers, OpMemoryNamedBarrierSuccess) { |
| 839 |
const std::string body = R"( |
| 840 |
%barrier = OpNamedBarrierInitialize %named_barrier %u32_4 |
| 841 |
OpMemoryNamedBarrier %barrier %workgroup %acquire_release_workgroup |
| 842 |
)"; |
| 843 |
|
| 844 |
CompileSuccessfully(GenerateKernelCode(body), SPV_ENV_UNIVERSAL_1_1); |
| 845 |
ASSERT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_UNIVERSAL_1_1)); |
| 846 |
} |
| 847 |
|
| 848 |
TEST_F(ValidateBarriers, OpMemoryNamedBarrierNotNamedBarrier) { |
| 849 |
const std::string body = R"( |
| 850 |
OpMemoryNamedBarrier %u32_1 %workgroup %acquire_release_workgroup |
| 851 |
)"; |
| 852 |
|
| 853 |
CompileSuccessfully(GenerateKernelCode(body), SPV_ENV_UNIVERSAL_1_1); |
| 854 |
ASSERT_EQ(SPV_ERROR_INVALID_DATA, |
| 855 |
ValidateInstructions(SPV_ENV_UNIVERSAL_1_1)); |
| 856 |
EXPECT_THAT(getDiagnosticString(), |
| 857 |
HasSubstr("MemoryNamedBarrier: expected Named Barrier to be of " |
| 858 |
"type OpTypeNamedBarrier")); |
| 859 |
} |
| 860 |
|
| 861 |
TEST_F(ValidateBarriers, OpMemoryNamedBarrierFloatMemoryScope) { |
| 862 |
const std::string body = R"( |
| 863 |
%barrier = OpNamedBarrierInitialize %named_barrier %u32_4 |
| 864 |
OpMemoryNamedBarrier %barrier %f32_1 %acquire_release_workgroup |
| 865 |
)"; |
| 866 |
|
| 867 |
CompileSuccessfully(GenerateKernelCode(body), SPV_ENV_UNIVERSAL_1_1); |
| 868 |
ASSERT_EQ(SPV_ERROR_INVALID_DATA, |
| 869 |
ValidateInstructions(SPV_ENV_UNIVERSAL_1_1)); |
| 870 |
EXPECT_THAT( |
| 871 |
getDiagnosticString(), |
| 872 |
HasSubstr("MemoryNamedBarrier: expected scope to be a 32-bit int")); |
| 873 |
} |
| 874 |
|
| 875 |
TEST_F(ValidateBarriers, OpMemoryNamedBarrierFloatMemorySemantics) { |
| 876 |
const std::string body = R"( |
| 877 |
%barrier = OpNamedBarrierInitialize %named_barrier %u32_4 |
| 878 |
OpMemoryNamedBarrier %barrier %workgroup %f32_0 |
| 879 |
)"; |
| 880 |
|
| 881 |
CompileSuccessfully(GenerateKernelCode(body), SPV_ENV_UNIVERSAL_1_1); |
| 882 |
ASSERT_EQ(SPV_ERROR_INVALID_DATA, |
| 883 |
ValidateInstructions(SPV_ENV_UNIVERSAL_1_1)); |
| 884 |
EXPECT_THAT( |
| 885 |
getDiagnosticString(), |
| 886 |
HasSubstr( |
| 887 |
"MemoryNamedBarrier: expected Memory Semantics to be a 32-bit int")); |
| 888 |
} |
| 889 |
|
| 890 |
TEST_F(ValidateBarriers, OpMemoryNamedBarrierAcquireAndRelease) { |
| 891 |
const std::string body = R"( |
| 892 |
%barrier = OpNamedBarrierInitialize %named_barrier %u32_4 |
| 893 |
OpMemoryNamedBarrier %barrier %workgroup %acquire_and_release |
| 894 |
)"; |
| 895 |
|
| 896 |
CompileSuccessfully(GenerateKernelCode(body), SPV_ENV_UNIVERSAL_1_1); |
| 897 |
ASSERT_EQ(SPV_ERROR_INVALID_DATA, |
| 898 |
ValidateInstructions(SPV_ENV_UNIVERSAL_1_1)); |
| 899 |
EXPECT_THAT(getDiagnosticString(), |
| 900 |
HasSubstr("MemoryNamedBarrier: Memory Semantics must have " |
| 901 |
"at most one non-relaxed memory order bit set")); |
| 902 |
} |
| 903 |
|
| 904 |
TEST_F(ValidateBarriers, TypeAsMemoryScope) { |
| 905 |
const std::string body = R"( |
| 906 |
OpMemoryBarrier %u32 %u32_0 |
| 907 |
)"; |
| 908 |
|
| 909 |
CompileSuccessfully(GenerateKernelCode(body), SPV_ENV_UNIVERSAL_1_1); |
| 910 |
EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_UNIVERSAL_1_1)); |
| 911 |
EXPECT_THAT(getDiagnosticString(), HasSubstr("Operand '5[%uint]' cannot be a " |
| 912 |
"type")); |
| 913 |
} |
| 914 |
|
| 915 |
TEST_F(ValidateBarriers, OutputMemoryKHRRequireVulkanMemoryModelKHR) { |
| 916 |
const std::string text = R"( |
| 917 |
OpCapability Shader |
| 918 |
OpMemoryModel Logical GLSL450 |
| 919 |
OpEntryPoint Fragment %1 "func" |
| 920 |
OpExecutionMode %1 OriginUpperLeft |
| 921 |
%2 = OpTypeVoid |
| 922 |
%3 = OpTypeInt 32 0 |
| 923 |
%semantics = OpConstant %3 4104 |
| 924 |
%5 = OpTypeFunction %2 |
| 925 |
%device = OpConstant %3 1 |
| 926 |
%1 = OpFunction %2 None %5 |
| 927 |
%7 = OpLabel |
| 928 |
OpControlBarrier %device %device %semantics |
| 929 |
OpReturn |
| 930 |
OpFunctionEnd |
| 931 |
)"; |
| 932 |
|
| 933 |
CompileSuccessfully(text); |
| 934 |
EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); |
| 935 |
EXPECT_THAT(getDiagnosticString(), |
| 936 |
HasSubstr("ControlBarrier: Memory Semantics OutputMemoryKHR " |
| 937 |
"requires capability VulkanMemoryModelKHR")); |
| 938 |
} |
| 939 |
|
| 940 |
TEST_F(ValidateBarriers, MakeAvailableKHRRequireVulkanMemoryModelKHR) { |
| 941 |
const std::string text = R"( |
| 942 |
OpCapability Shader |
| 943 |
OpMemoryModel Logical GLSL450 |
| 944 |
OpEntryPoint Fragment %1 "func" |
| 945 |
OpExecutionMode %1 OriginUpperLeft |
| 946 |
%2 = OpTypeVoid |
| 947 |
%3 = OpTypeInt 32 0 |
| 948 |
%semantics = OpConstant %3 8264 |
| 949 |
%5 = OpTypeFunction %2 |
| 950 |
%device = OpConstant %3 1 |
| 951 |
%1 = OpFunction %2 None %5 |
| 952 |
%7 = OpLabel |
| 953 |
OpControlBarrier %device %device %semantics |
| 954 |
OpReturn |
| 955 |
OpFunctionEnd |
| 956 |
)"; |
| 957 |
|
| 958 |
CompileSuccessfully(text); |
| 959 |
EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); |
| 960 |
EXPECT_THAT(getDiagnosticString(), |
| 961 |
HasSubstr("ControlBarrier: Memory Semantics MakeAvailableKHR " |
| 962 |
"requires capability VulkanMemoryModelKHR")); |
| 963 |
} |
| 964 |
|
| 965 |
TEST_F(ValidateBarriers, MakeVisibleKHRRequireVulkanMemoryModelKHR) { |
| 966 |
const std::string text = R"( |
| 967 |
OpCapability Shader |
| 968 |
OpMemoryModel Logical GLSL450 |
| 969 |
OpEntryPoint Fragment %1 "func" |
| 970 |
OpExecutionMode %1 OriginUpperLeft |
| 971 |
%2 = OpTypeVoid |
| 972 |
%3 = OpTypeInt 32 0 |
| 973 |
%semantics = OpConstant %3 16456 |
| 974 |
%5 = OpTypeFunction %2 |
| 975 |
%device = OpConstant %3 1 |
| 976 |
%1 = OpFunction %2 None %5 |
| 977 |
%7 = OpLabel |
| 978 |
OpControlBarrier %device %device %semantics |
| 979 |
OpReturn |
| 980 |
OpFunctionEnd |
| 981 |
)"; |
| 982 |
|
| 983 |
CompileSuccessfully(text); |
| 984 |
EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); |
| 985 |
EXPECT_THAT(getDiagnosticString(), |
| 986 |
HasSubstr("ControlBarrier: Memory Semantics MakeVisibleKHR " |
| 987 |
"requires capability VulkanMemoryModelKHR")); |
| 988 |
} |
| 989 |
|
| 990 |
TEST_F(ValidateBarriers, SemanticsSpecConstantShader) { |
| 991 |
const std::string spirv = R"( |
| 992 |
OpCapability Shader |
| 993 |
OpMemoryModel Logical GLSL450 |
| 994 |
OpEntryPoint Fragment %func "func" |
| 995 |
OpExecutionMode %func OriginUpperLeft |
| 996 |
%void = OpTypeVoid |
| 997 |
%int = OpTypeInt 32 0 |
| 998 |
%ptr_int_workgroup = OpTypePointer Workgroup %int |
| 999 |
%var = OpVariable %ptr_int_workgroup Workgroup |
| 1000 |
%voidfn = OpTypeFunction %void |
| 1001 |
%spec_const = OpSpecConstant %int 0 |
| 1002 |
%workgroup = OpConstant %int 2 |
| 1003 |
%func = OpFunction %void None %voidfn |
| 1004 |
%entry = OpLabel |
| 1005 |
OpMemoryBarrier %workgroup %spec_const |
| 1006 |
OpReturn |
| 1007 |
OpFunctionEnd |
| 1008 |
)"; |
| 1009 |
|
| 1010 |
CompileSuccessfully(spirv); |
| 1011 |
EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); |
| 1012 |
EXPECT_THAT(getDiagnosticString(), |
| 1013 |
HasSubstr("Memory Semantics ids must be OpConstant when Shader " |
| 1014 |
"capability is present")); |
| 1015 |
} |
| 1016 |
|
| 1017 |
TEST_F(ValidateBarriers, SemanticsSpecConstantKernel) { |
| 1018 |
const std::string spirv = R"( |
| 1019 |
OpCapability Kernel |
| 1020 |
OpCapability Linkage |
| 1021 |
OpMemoryModel Logical OpenCL |
| 1022 |
%void = OpTypeVoid |
| 1023 |
%int = OpTypeInt 32 0 |
| 1024 |
%ptr_int_workgroup = OpTypePointer Workgroup %int |
| 1025 |
%var = OpVariable %ptr_int_workgroup Workgroup |
| 1026 |
%voidfn = OpTypeFunction %void |
| 1027 |
%spec_const = OpSpecConstant %int 0 |
| 1028 |
%workgroup = OpConstant %int 2 |
| 1029 |
%func = OpFunction %void None %voidfn |
| 1030 |
%entry = OpLabel |
| 1031 |
OpMemoryBarrier %workgroup %spec_const |
| 1032 |
OpReturn |
| 1033 |
OpFunctionEnd |
| 1034 |
)"; |
| 1035 |
|
| 1036 |
CompileSuccessfully(spirv); |
| 1037 |
EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); |
| 1038 |
} |
| 1039 |
|
| 1040 |
TEST_F(ValidateBarriers, ScopeSpecConstantShader) { |
| 1041 |
const std::string spirv = R"( |
| 1042 |
OpCapability Shader |
| 1043 |
OpMemoryModel Logical GLSL450 |
| 1044 |
OpEntryPoint Fragment %func "func" |
| 1045 |
OpExecutionMode %func OriginUpperLeft |
| 1046 |
%void = OpTypeVoid |
| 1047 |
%int = OpTypeInt 32 0 |
| 1048 |
%ptr_int_workgroup = OpTypePointer Workgroup %int |
| 1049 |
%var = OpVariable %ptr_int_workgroup Workgroup |
| 1050 |
%voidfn = OpTypeFunction %void |
| 1051 |
%spec_const = OpSpecConstant %int 0 |
| 1052 |
%relaxed = OpConstant %int 0 |
| 1053 |
%func = OpFunction %void None %voidfn |
| 1054 |
%entry = OpLabel |
| 1055 |
OpMemoryBarrier %spec_const %relaxed |
| 1056 |
OpReturn |
| 1057 |
OpFunctionEnd |
| 1058 |
)"; |
| 1059 |
|
| 1060 |
CompileSuccessfully(spirv); |
| 1061 |
EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); |
| 1062 |
EXPECT_THAT(getDiagnosticString(), |
| 1063 |
HasSubstr("Scope ids must be OpConstant when Shader " |
| 1064 |
"capability is present")); |
| 1065 |
} |
| 1066 |
|
| 1067 |
TEST_F(ValidateBarriers, ScopeSpecConstantKernel) { |
| 1068 |
const std::string spirv = R"( |
| 1069 |
OpCapability Kernel |
| 1070 |
OpCapability Linkage |
| 1071 |
OpMemoryModel Logical OpenCL |
| 1072 |
%void = OpTypeVoid |
| 1073 |
%int = OpTypeInt 32 0 |
| 1074 |
%ptr_int_workgroup = OpTypePointer Workgroup %int |
| 1075 |
%var = OpVariable %ptr_int_workgroup Workgroup |
| 1076 |
%voidfn = OpTypeFunction %void |
| 1077 |
%spec_const = OpSpecConstant %int 0 |
| 1078 |
%relaxed = OpConstant %int 0 |
| 1079 |
%func = OpFunction %void None %voidfn |
| 1080 |
%entry = OpLabel |
| 1081 |
OpMemoryBarrier %spec_const %relaxed |
| 1082 |
OpReturn |
| 1083 |
OpFunctionEnd |
| 1084 |
)"; |
| 1085 |
|
| 1086 |
CompileSuccessfully(spirv); |
| 1087 |
EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); |
| 1088 |
} |
| 1089 |
|
| 1090 |
TEST_F(ValidateBarriers, VulkanMemoryModelDeviceScopeBad) { |
| 1091 |
const std::string text = R"( |
| 1092 |
OpCapability Shader |
| 1093 |
OpCapability VulkanMemoryModelKHR |
| 1094 |
OpExtension "SPV_KHR_vulkan_memory_model" |
| 1095 |
OpMemoryModel Logical VulkanKHR |
| 1096 |
OpEntryPoint Fragment %func "func" |
| 1097 |
OpExecutionMode %func OriginUpperLeft |
| 1098 |
%void = OpTypeVoid |
| 1099 |
%int = OpTypeInt 32 0 |
| 1100 |
%device = OpConstant %int 1 |
| 1101 |
%semantics = OpConstant %int 72 |
| 1102 |
%functy = OpTypeFunction %void |
| 1103 |
%func = OpFunction %void None %functy |
| 1104 |
%1 = OpLabel |
| 1105 |
OpMemoryBarrier %device %semantics |
| 1106 |
OpReturn |
| 1107 |
OpFunctionEnd |
| 1108 |
)"; |
| 1109 |
|
| 1110 |
CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_3); |
| 1111 |
EXPECT_EQ(SPV_ERROR_INVALID_DATA, |
| 1112 |
ValidateInstructions(SPV_ENV_UNIVERSAL_1_3)); |
| 1113 |
EXPECT_THAT( |
| 1114 |
getDiagnosticString(), |
| 1115 |
HasSubstr("Use of device scope with VulkanKHR memory model requires the " |
| 1116 |
"VulkanMemoryModelDeviceScopeKHR capability")); |
| 1117 |
} |
| 1118 |
|
| 1119 |
TEST_F(ValidateBarriers, VulkanMemoryModelDeviceScopeGood) { |
| 1120 |
const std::string text = R"( |
| 1121 |
OpCapability Shader |
| 1122 |
OpCapability VulkanMemoryModelKHR |
| 1123 |
OpCapability VulkanMemoryModelDeviceScopeKHR |
| 1124 |
OpExtension "SPV_KHR_vulkan_memory_model" |
| 1125 |
OpMemoryModel Logical VulkanKHR |
| 1126 |
OpEntryPoint Fragment %func "func" |
| 1127 |
OpExecutionMode %func OriginUpperLeft |
| 1128 |
%void = OpTypeVoid |
| 1129 |
%int = OpTypeInt 32 0 |
| 1130 |
%device = OpConstant %int 1 |
| 1131 |
%semantics = OpConstant %int 72 |
| 1132 |
%functy = OpTypeFunction %void |
| 1133 |
%func = OpFunction %void None %functy |
| 1134 |
%1 = OpLabel |
| 1135 |
OpMemoryBarrier %device %semantics |
| 1136 |
OpReturn |
| 1137 |
OpFunctionEnd |
| 1138 |
)"; |
| 1139 |
|
| 1140 |
CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_3); |
| 1141 |
EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_UNIVERSAL_1_3)); |
| 1142 |
} |
| 1143 |
|
| 1144 |
TEST_F(ValidateBarriers, CooperativeMatrixSpecConstantVolatile) { |
| 1145 |
const std::string text = R"( |
| 1146 |
OpCapability Shader |
| 1147 |
OpCapability VulkanMemoryModelKHR |
| 1148 |
OpCapability VulkanMemoryModelDeviceScopeKHR |
| 1149 |
OpCapability CooperativeMatrixNV |
| 1150 |
OpCapability Linkage |
| 1151 |
OpExtension "SPV_KHR_vulkan_memory_model" |
| 1152 |
OpExtension "SPV_NV_cooperative_matrix" |
| 1153 |
OpMemoryModel Logical VulkanKHR |
| 1154 |
%void = OpTypeVoid |
| 1155 |
%int = OpTypeInt 32 0 |
| 1156 |
%device = OpConstant %int 1 |
| 1157 |
%semantics = OpSpecConstant %int 32768 |
| 1158 |
%functy = OpTypeFunction %void |
| 1159 |
%func = OpFunction %void None %functy |
| 1160 |
%1 = OpLabel |
| 1161 |
OpControlBarrier %device %device %semantics |
| 1162 |
OpReturn |
| 1163 |
OpFunctionEnd |
| 1164 |
)"; |
| 1165 |
|
| 1166 |
CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_3); |
| 1167 |
EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_UNIVERSAL_1_3)); |
| 1168 |
} |
| 1169 |
|
| 1170 |
TEST_F(ValidateBarriers, CooperativeMatrixNonConstantSemantics) { |
| 1171 |
const std::string text = R"( |
| 1172 |
OpCapability Shader |
| 1173 |
OpCapability VulkanMemoryModelKHR |
| 1174 |
OpCapability VulkanMemoryModelDeviceScopeKHR |
| 1175 |
OpCapability CooperativeMatrixNV |
| 1176 |
OpCapability Linkage |
| 1177 |
OpExtension "SPV_KHR_vulkan_memory_model" |
| 1178 |
OpExtension "SPV_NV_cooperative_matrix" |
| 1179 |
OpMemoryModel Logical VulkanKHR |
| 1180 |
%void = OpTypeVoid |
| 1181 |
%int = OpTypeInt 32 0 |
| 1182 |
%device = OpConstant %int 1 |
| 1183 |
%semantics = OpUndef %int |
| 1184 |
%functy = OpTypeFunction %void |
| 1185 |
%func = OpFunction %void None %functy |
| 1186 |
%1 = OpLabel |
| 1187 |
OpControlBarrier %device %device %semantics |
| 1188 |
OpReturn |
| 1189 |
OpFunctionEnd |
| 1190 |
)"; |
| 1191 |
|
| 1192 |
CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_3); |
| 1193 |
EXPECT_EQ(SPV_ERROR_INVALID_DATA, |
| 1194 |
ValidateInstructions(SPV_ENV_UNIVERSAL_1_3)); |
| 1195 |
EXPECT_THAT(getDiagnosticString(), |
| 1196 |
HasSubstr("Memory Semantics must be a constant instruction when " |
| 1197 |
"CooperativeMatrixNV capability is present")); |
| 1198 |
} |
| 1199 |
|
| 1200 |
TEST_F(ValidateBarriers, OpMemoryBarrierShaderCallRayGenSuccess) { |
| 1201 |
const std::string body = |
| 1202 |
"OpMemoryBarrier %shadercall %release_uniform_workgroup"; |
| 1203 |
|
| 1204 |
CompileSuccessfully(GenerateShaderCodeImpl(body, |
| 1205 |
// capabilities_and_extensions |
| 1206 |
R"( |
| 1207 |
OpCapability VulkanMemoryModelKHR |
| 1208 |
OpCapability RayTracingKHR |
| 1209 |
OpExtension "SPV_KHR_vulkan_memory_model" |
| 1210 |
OpExtension "SPV_KHR_ray_tracing" |
| 1211 |
)", |
| 1212 |
// definitions |
| 1213 |
"", |
| 1214 |
// execution_model |
| 1215 |
"RayGenerationKHR", |
| 1216 |
// memory_model |
| 1217 |
"OpMemoryModel Logical VulkanKHR"), |
| 1218 |
SPV_ENV_VULKAN_1_1); |
| 1219 |
|
| 1220 |
ASSERT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_1)); |
| 1221 |
} |
| 1222 |
|
| 1223 |
TEST_F(ValidateBarriers, OpMemoryBarrierShaderCallComputeFailure) { |
| 1224 |
const std::string body = |
| 1225 |
"OpMemoryBarrier %shadercall %release_uniform_workgroup"; |
| 1226 |
|
| 1227 |
CompileSuccessfully(GenerateShaderCodeImpl(body, |
| 1228 |
// capabilities_and_extensions |
| 1229 |
R"( |
| 1230 |
OpCapability VulkanMemoryModelKHR |
| 1231 |
OpExtension "SPV_KHR_vulkan_memory_model" |
| 1232 |
)", |
| 1233 |
// definitions |
| 1234 |
"", |
| 1235 |
// execution_model |
| 1236 |
"GLCompute", |
| 1237 |
// memory_model |
| 1238 |
"OpMemoryModel Logical VulkanKHR"), |
| 1239 |
SPV_ENV_VULKAN_1_1); |
| 1240 |
|
| 1241 |
ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_1)); |
| 1242 |
EXPECT_THAT(getDiagnosticString(), |
| 1243 |
AnyVUID("VUID-StandaloneSpirv-None-04640")); |
| 1244 |
EXPECT_THAT( |
| 1245 |
getDiagnosticString(), |
| 1246 |
HasSubstr( |
| 1247 |
"ShaderCallKHR Memory Scope requires a ray tracing execution model")); |
| 1248 |
} |
| 1249 |
|
| 1250 |
TEST_F(ValidateBarriers, OpControlBarrierShaderCallRayGenFailure) { |
| 1251 |
const std::string body = "OpControlBarrier %shadercall %shadercall %none"; |
| 1252 |
|
| 1253 |
CompileSuccessfully(GenerateShaderCodeImpl(body, |
| 1254 |
// capabilities_and_extensions |
| 1255 |
R"( |
| 1256 |
OpCapability VulkanMemoryModelKHR |
| 1257 |
OpCapability RayTracingKHR |
| 1258 |
OpExtension "SPV_KHR_vulkan_memory_model" |
| 1259 |
OpExtension "SPV_KHR_ray_tracing" |
| 1260 |
)", |
| 1261 |
// definitions |
| 1262 |
"", |
| 1263 |
// execution_model |
| 1264 |
"RayGenerationKHR", |
| 1265 |
// memory_model |
| 1266 |
"OpMemoryModel Logical VulkanKHR"), |
| 1267 |
SPV_ENV_VULKAN_1_1); |
| 1268 |
|
| 1269 |
ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_1)); |
| 1270 |
EXPECT_THAT(getDiagnosticString(), |
| 1271 |
AnyVUID("VUID-StandaloneSpirv-None-04636")); |
| 1272 |
EXPECT_THAT(getDiagnosticString(), |
| 1273 |
HasSubstr("in Vulkan environment Execution Scope is limited to " |
| 1274 |
"Workgroup and Subgroup")); |
| 1275 |
} |
| 1276 |
|
| 1277 |
} // namespace |
| 1278 |
} // namespace val |
| 1279 |
} // namespace spvtools |