diff options
| author | 2022-01-29 13:46:06 -0500 | |
|---|---|---|
| committer | 2022-01-29 19:55:53 -0500 | |
| commit | ad58d7eae7bd34c881720ed6650c400cb549fcd6 (patch) | |
| tree | 135bb94ab1645a4080ec2e6f9914351bd315ee2a /src/shader_recompiler/backend/spirv | |
| parent | Merge pull request #7791 from german77/wall_clock (diff) | |
| download | yuzu-ad58d7eae7bd34c881720ed6650c400cb549fcd6.tar.gz yuzu-ad58d7eae7bd34c881720ed6650c400cb549fcd6.tar.xz yuzu-ad58d7eae7bd34c881720ed6650c400cb549fcd6.zip | |
shaders: Add U64->U32x2 Atomic fallback functions
Diffstat (limited to 'src/shader_recompiler/backend/spirv')
| -rw-r--r-- | src/shader_recompiler/backend/spirv/emit_spirv_atomic.cpp | 119 | ||||
| -rw-r--r-- | src/shader_recompiler/backend/spirv/emit_spirv_instructions.h | 30 |
2 files changed, 148 insertions, 1 deletions
diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_atomic.cpp b/src/shader_recompiler/backend/spirv/emit_spirv_atomic.cpp index 46ba52a25..d3cbb14a9 100644 --- a/src/shader_recompiler/backend/spirv/emit_spirv_atomic.cpp +++ b/src/shader_recompiler/backend/spirv/emit_spirv_atomic.cpp | |||
| @@ -82,6 +82,17 @@ Id StorageAtomicU64(EmitContext& ctx, const IR::Value& binding, const IR::Value& | |||
| 82 | ctx.OpStore(pointer, ctx.OpBitcast(ctx.U32[2], result)); | 82 | ctx.OpStore(pointer, ctx.OpBitcast(ctx.U32[2], result)); |
| 83 | return original_value; | 83 | return original_value; |
| 84 | } | 84 | } |
| 85 | |||
| 86 | Id StorageAtomicU32x2(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, Id value, | ||
| 87 | Id (Sirit::Module::*non_atomic_func)(Id, Id, Id)) { | ||
| 88 | LOG_WARNING(Shader_SPIRV, "Int64 atomics not supported, fallback to non-atomic"); | ||
| 89 | const Id pointer{StoragePointer(ctx, ctx.storage_types.U32x2, &StorageDefinitions::U32x2, | ||
| 90 | binding, offset, sizeof(u32[2]))}; | ||
| 91 | const Id original_value{ctx.OpLoad(ctx.U32[2], pointer)}; | ||
| 92 | const Id result{(ctx.*non_atomic_func)(ctx.U32[2], value, original_value)}; | ||
| 93 | ctx.OpStore(pointer, result); | ||
| 94 | return original_value; | ||
| 95 | } | ||
| 85 | } // Anonymous namespace | 96 | } // Anonymous namespace |
| 86 | 97 | ||
| 87 | Id EmitSharedAtomicIAdd32(EmitContext& ctx, Id offset, Id value) { | 98 | Id EmitSharedAtomicIAdd32(EmitContext& ctx, Id offset, Id value) { |
| @@ -141,7 +152,7 @@ Id EmitSharedAtomicExchange64(EmitContext& ctx, Id offset, Id value) { | |||
| 141 | const auto [scope, semantics]{AtomicArgs(ctx)}; | 152 | const auto [scope, semantics]{AtomicArgs(ctx)}; |
| 142 | return ctx.OpAtomicExchange(ctx.U64, pointer, scope, semantics, value); | 153 | return ctx.OpAtomicExchange(ctx.U64, pointer, scope, semantics, value); |
| 143 | } | 154 | } |
| 144 | LOG_ERROR(Shader_SPIRV, "Int64 atomics not supported, fallback to non-atomic"); | 155 | LOG_WARNING(Shader_SPIRV, "Int64 atomics not supported, fallback to non-atomic"); |
| 145 | const Id pointer_1{SharedPointer(ctx, offset, 0)}; | 156 | const Id pointer_1{SharedPointer(ctx, offset, 0)}; |
| 146 | const Id pointer_2{SharedPointer(ctx, offset, 1)}; | 157 | const Id pointer_2{SharedPointer(ctx, offset, 1)}; |
| 147 | const Id value_1{ctx.OpLoad(ctx.U32[1], pointer_1)}; | 158 | const Id value_1{ctx.OpLoad(ctx.U32[1], pointer_1)}; |
| @@ -152,6 +163,18 @@ Id EmitSharedAtomicExchange64(EmitContext& ctx, Id offset, Id value) { | |||
| 152 | return ctx.OpBitcast(ctx.U64, ctx.OpCompositeConstruct(ctx.U32[2], value_1, value_2)); | 163 | return ctx.OpBitcast(ctx.U64, ctx.OpCompositeConstruct(ctx.U32[2], value_1, value_2)); |
| 153 | } | 164 | } |
| 154 | 165 | ||
| 166 | Id EmitSharedAtomicExchange32x2(EmitContext& ctx, Id offset, Id value) { | ||
| 167 | LOG_WARNING(Shader_SPIRV, "Int64 atomics not supported, fallback to non-atomic"); | ||
| 168 | const Id pointer_1{SharedPointer(ctx, offset, 0)}; | ||
| 169 | const Id pointer_2{SharedPointer(ctx, offset, 1)}; | ||
| 170 | const Id value_1{ctx.OpLoad(ctx.U32[1], pointer_1)}; | ||
| 171 | const Id value_2{ctx.OpLoad(ctx.U32[1], pointer_2)}; | ||
| 172 | const Id new_vector{ctx.OpBitcast(ctx.U32[2], value)}; | ||
| 173 | ctx.OpStore(pointer_1, ctx.OpCompositeExtract(ctx.U32[1], new_vector, 0U)); | ||
| 174 | ctx.OpStore(pointer_2, ctx.OpCompositeExtract(ctx.U32[1], new_vector, 1U)); | ||
| 175 | return ctx.OpCompositeConstruct(ctx.U32[2], value_1, value_2); | ||
| 176 | } | ||
| 177 | |||
| 155 | Id EmitStorageAtomicIAdd32(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, | 178 | Id EmitStorageAtomicIAdd32(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, |
| 156 | Id value) { | 179 | Id value) { |
| 157 | return StorageAtomicU32(ctx, binding, offset, value, &Sirit::Module::OpAtomicIAdd); | 180 | return StorageAtomicU32(ctx, binding, offset, value, &Sirit::Module::OpAtomicIAdd); |
| @@ -275,6 +298,56 @@ Id EmitStorageAtomicExchange64(EmitContext& ctx, const IR::Value& binding, const | |||
| 275 | return original; | 298 | return original; |
| 276 | } | 299 | } |
| 277 | 300 | ||
| 301 | Id EmitStorageAtomicIAdd32x2(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, | ||
| 302 | Id value) { | ||
| 303 | return StorageAtomicU32x2(ctx, binding, offset, value, &Sirit::Module::OpIAdd); | ||
| 304 | } | ||
| 305 | |||
| 306 | Id EmitStorageAtomicSMin32x2(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, | ||
| 307 | Id value) { | ||
| 308 | return StorageAtomicU32x2(ctx, binding, offset, value, &Sirit::Module::OpSMin); | ||
| 309 | } | ||
| 310 | |||
| 311 | Id EmitStorageAtomicUMin32x2(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, | ||
| 312 | Id value) { | ||
| 313 | return StorageAtomicU32x2(ctx, binding, offset, value, &Sirit::Module::OpUMin); | ||
| 314 | } | ||
| 315 | |||
| 316 | Id EmitStorageAtomicSMax32x2(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, | ||
| 317 | Id value) { | ||
| 318 | return StorageAtomicU32x2(ctx, binding, offset, value, &Sirit::Module::OpSMax); | ||
| 319 | } | ||
| 320 | |||
| 321 | Id EmitStorageAtomicUMax32x2(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, | ||
| 322 | Id value) { | ||
| 323 | return StorageAtomicU32x2(ctx, binding, offset, value, &Sirit::Module::OpUMax); | ||
| 324 | } | ||
| 325 | |||
| 326 | Id EmitStorageAtomicAnd32x2(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, | ||
| 327 | Id value) { | ||
| 328 | return StorageAtomicU32x2(ctx, binding, offset, value, &Sirit::Module::OpBitwiseAnd); | ||
| 329 | } | ||
| 330 | |||
| 331 | Id EmitStorageAtomicOr32x2(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, | ||
| 332 | Id value) { | ||
| 333 | return StorageAtomicU32x2(ctx, binding, offset, value, &Sirit::Module::OpBitwiseOr); | ||
| 334 | } | ||
| 335 | |||
| 336 | Id EmitStorageAtomicXor32x2(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, | ||
| 337 | Id value) { | ||
| 338 | return StorageAtomicU32x2(ctx, binding, offset, value, &Sirit::Module::OpBitwiseXor); | ||
| 339 | } | ||
| 340 | |||
| 341 | Id EmitStorageAtomicExchange32x2(EmitContext& ctx, const IR::Value& binding, | ||
| 342 | const IR::Value& offset, Id value) { | ||
| 343 | LOG_WARNING(Shader_SPIRV, "Int64 atomics not supported, fallback to non-atomic"); | ||
| 344 | const Id pointer{StoragePointer(ctx, ctx.storage_types.U32x2, &StorageDefinitions::U32x2, | ||
| 345 | binding, offset, sizeof(u32[2]))}; | ||
| 346 | const Id original{ctx.OpLoad(ctx.U32[2], pointer)}; | ||
| 347 | ctx.OpStore(pointer, value); | ||
| 348 | return original; | ||
| 349 | } | ||
| 350 | |||
| 278 | Id EmitStorageAtomicAddF32(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, | 351 | Id EmitStorageAtomicAddF32(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, |
| 279 | Id value) { | 352 | Id value) { |
| 280 | const Id ssbo{ctx.ssbos[binding.U32()].U32}; | 353 | const Id ssbo{ctx.ssbos[binding.U32()].U32}; |
| @@ -418,6 +491,50 @@ Id EmitGlobalAtomicExchange64(EmitContext&) { | |||
| 418 | throw NotImplementedException("SPIR-V Instruction"); | 491 | throw NotImplementedException("SPIR-V Instruction"); |
| 419 | } | 492 | } |
| 420 | 493 | ||
| 494 | Id EmitGlobalAtomicIAdd32x2(EmitContext&) { | ||
| 495 | throw NotImplementedException("SPIR-V Instruction"); | ||
| 496 | } | ||
| 497 | |||
| 498 | Id EmitGlobalAtomicSMin32x2(EmitContext&) { | ||
| 499 | throw NotImplementedException("SPIR-V Instruction"); | ||
| 500 | } | ||
| 501 | |||
| 502 | Id EmitGlobalAtomicUMin32x2(EmitContext&) { | ||
| 503 | throw NotImplementedException("SPIR-V Instruction"); | ||
| 504 | } | ||
| 505 | |||
| 506 | Id EmitGlobalAtomicSMax32x2(EmitContext&) { | ||
| 507 | throw NotImplementedException("SPIR-V Instruction"); | ||
| 508 | } | ||
| 509 | |||
| 510 | Id EmitGlobalAtomicUMax32x2(EmitContext&) { | ||
| 511 | throw NotImplementedException("SPIR-V Instruction"); | ||
| 512 | } | ||
| 513 | |||
| 514 | Id EmitGlobalAtomicInc32x2(EmitContext&) { | ||
| 515 | throw NotImplementedException("SPIR-V Instruction"); | ||
| 516 | } | ||
| 517 | |||
| 518 | Id EmitGlobalAtomicDec32x2(EmitContext&) { | ||
| 519 | throw NotImplementedException("SPIR-V Instruction"); | ||
| 520 | } | ||
| 521 | |||
| 522 | Id EmitGlobalAtomicAnd32x2(EmitContext&) { | ||
| 523 | throw NotImplementedException("SPIR-V Instruction"); | ||
| 524 | } | ||
| 525 | |||
| 526 | Id EmitGlobalAtomicOr32x2(EmitContext&) { | ||
| 527 | throw NotImplementedException("SPIR-V Instruction"); | ||
| 528 | } | ||
| 529 | |||
| 530 | Id EmitGlobalAtomicXor32x2(EmitContext&) { | ||
| 531 | throw NotImplementedException("SPIR-V Instruction"); | ||
| 532 | } | ||
| 533 | |||
| 534 | Id EmitGlobalAtomicExchange32x2(EmitContext&) { | ||
| 535 | throw NotImplementedException("SPIR-V Instruction"); | ||
| 536 | } | ||
| 537 | |||
| 421 | Id EmitGlobalAtomicAddF32(EmitContext&) { | 538 | Id EmitGlobalAtomicAddF32(EmitContext&) { |
| 422 | throw NotImplementedException("SPIR-V Instruction"); | 539 | throw NotImplementedException("SPIR-V Instruction"); |
| 423 | } | 540 | } |
diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_instructions.h b/src/shader_recompiler/backend/spirv/emit_spirv_instructions.h index 887112deb..f263b41b0 100644 --- a/src/shader_recompiler/backend/spirv/emit_spirv_instructions.h +++ b/src/shader_recompiler/backend/spirv/emit_spirv_instructions.h | |||
| @@ -335,6 +335,7 @@ Id EmitSharedAtomicOr32(EmitContext& ctx, Id pointer_offset, Id value); | |||
| 335 | Id EmitSharedAtomicXor32(EmitContext& ctx, Id pointer_offset, Id value); | 335 | Id EmitSharedAtomicXor32(EmitContext& ctx, Id pointer_offset, Id value); |
| 336 | Id EmitSharedAtomicExchange32(EmitContext& ctx, Id pointer_offset, Id value); | 336 | Id EmitSharedAtomicExchange32(EmitContext& ctx, Id pointer_offset, Id value); |
| 337 | Id EmitSharedAtomicExchange64(EmitContext& ctx, Id pointer_offset, Id value); | 337 | Id EmitSharedAtomicExchange64(EmitContext& ctx, Id pointer_offset, Id value); |
| 338 | Id EmitSharedAtomicExchange32x2(EmitContext& ctx, Id pointer_offset, Id value); | ||
| 338 | Id EmitStorageAtomicIAdd32(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, | 339 | Id EmitStorageAtomicIAdd32(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, |
| 339 | Id value); | 340 | Id value); |
| 340 | Id EmitStorageAtomicSMin32(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, | 341 | Id EmitStorageAtomicSMin32(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, |
| @@ -375,6 +376,24 @@ Id EmitStorageAtomicXor64(EmitContext& ctx, const IR::Value& binding, const IR:: | |||
| 375 | Id value); | 376 | Id value); |
| 376 | Id EmitStorageAtomicExchange64(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, | 377 | Id EmitStorageAtomicExchange64(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, |
| 377 | Id value); | 378 | Id value); |
| 379 | Id EmitStorageAtomicIAdd32x2(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, | ||
| 380 | Id value); | ||
| 381 | Id EmitStorageAtomicSMin32x2(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, | ||
| 382 | Id value); | ||
| 383 | Id EmitStorageAtomicUMin32x2(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, | ||
| 384 | Id value); | ||
| 385 | Id EmitStorageAtomicSMax32x2(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, | ||
| 386 | Id value); | ||
| 387 | Id EmitStorageAtomicUMax32x2(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, | ||
| 388 | Id value); | ||
| 389 | Id EmitStorageAtomicAnd32x2(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, | ||
| 390 | Id value); | ||
| 391 | Id EmitStorageAtomicOr32x2(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, | ||
| 392 | Id value); | ||
| 393 | Id EmitStorageAtomicXor32x2(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, | ||
| 394 | Id value); | ||
| 395 | Id EmitStorageAtomicExchange32x2(EmitContext& ctx, const IR::Value& binding, | ||
| 396 | const IR::Value& offset, Id value); | ||
| 378 | Id EmitStorageAtomicAddF32(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, | 397 | Id EmitStorageAtomicAddF32(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, |
| 379 | Id value); | 398 | Id value); |
| 380 | Id EmitStorageAtomicAddF16x2(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, | 399 | Id EmitStorageAtomicAddF16x2(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, |
| @@ -411,6 +430,17 @@ Id EmitGlobalAtomicAnd64(EmitContext& ctx); | |||
| 411 | Id EmitGlobalAtomicOr64(EmitContext& ctx); | 430 | Id EmitGlobalAtomicOr64(EmitContext& ctx); |
| 412 | Id EmitGlobalAtomicXor64(EmitContext& ctx); | 431 | Id EmitGlobalAtomicXor64(EmitContext& ctx); |
| 413 | Id EmitGlobalAtomicExchange64(EmitContext& ctx); | 432 | Id EmitGlobalAtomicExchange64(EmitContext& ctx); |
| 433 | Id EmitGlobalAtomicIAdd32x2(EmitContext& ctx); | ||
| 434 | Id EmitGlobalAtomicSMin32x2(EmitContext& ctx); | ||
| 435 | Id EmitGlobalAtomicUMin32x2(EmitContext& ctx); | ||
| 436 | Id EmitGlobalAtomicSMax32x2(EmitContext& ctx); | ||
| 437 | Id EmitGlobalAtomicUMax32x2(EmitContext& ctx); | ||
| 438 | Id EmitGlobalAtomicInc32x2(EmitContext& ctx); | ||
| 439 | Id EmitGlobalAtomicDec32x2(EmitContext& ctx); | ||
| 440 | Id EmitGlobalAtomicAnd32x2(EmitContext& ctx); | ||
| 441 | Id EmitGlobalAtomicOr32x2(EmitContext& ctx); | ||
| 442 | Id EmitGlobalAtomicXor32x2(EmitContext& ctx); | ||
| 443 | Id EmitGlobalAtomicExchange32x2(EmitContext& ctx); | ||
| 414 | Id EmitGlobalAtomicAddF32(EmitContext& ctx); | 444 | Id EmitGlobalAtomicAddF32(EmitContext& ctx); |
| 415 | Id EmitGlobalAtomicAddF16x2(EmitContext& ctx); | 445 | Id EmitGlobalAtomicAddF16x2(EmitContext& ctx); |
| 416 | Id EmitGlobalAtomicAddF32x2(EmitContext& ctx); | 446 | Id EmitGlobalAtomicAddF32x2(EmitContext& ctx); |