diff options
Diffstat (limited to 'src/shader_recompiler/backend')
| -rw-r--r-- | src/shader_recompiler/backend/glsl/emit_glsl_atomic.cpp | 64 |
1 files changed, 55 insertions, 9 deletions
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_atomic.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_atomic.cpp index 782e0e496..a409a7ab3 100644 --- a/src/shader_recompiler/backend/glsl/emit_glsl_atomic.cpp +++ b/src/shader_recompiler/backend/glsl/emit_glsl_atomic.cpp | |||
| @@ -274,47 +274,93 @@ void EmitStorageAtomicExchange64(EmitContext& ctx, IR::Inst& inst, const IR::Val | |||
| 274 | 274 | ||
| 275 | void EmitStorageAtomicIAdd32x2(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, | 275 | void EmitStorageAtomicIAdd32x2(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, |
| 276 | const IR::Value& offset, std::string_view value) { | 276 | const IR::Value& offset, std::string_view value) { |
| 277 | throw NotImplementedException("GLSL Instrucion"); | 277 | LOG_WARNING(Shader_GLSL, "Int64 atomics not supported, fallback to non-atomic"); |
| 278 | ctx.AddU32x2("{}=uvec2({}_ssbo{}[{}>>2],{}_ssbo{}[({}>>2)+1]);", inst, ctx.stage_name, | ||
| 279 | binding.U32(), ctx.var_alloc.Consume(offset), ctx.stage_name, binding.U32(), | ||
| 280 | ctx.var_alloc.Consume(offset)); | ||
| 281 | ctx.Add("{}_ssbo{}[{}>>2]+={}.x;{}_ssbo{}[({}>>2)+1]+={}.y;", ctx.stage_name, binding.U32(), | ||
| 282 | ctx.var_alloc.Consume(offset), value, ctx.stage_name, binding.U32(), | ||
| 283 | ctx.var_alloc.Consume(offset), value); | ||
| 278 | } | 284 | } |
| 279 | 285 | ||
| 280 | void EmitStorageAtomicSMin32x2(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, | 286 | void EmitStorageAtomicSMin32x2(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, |
| 281 | const IR::Value& offset, std::string_view value) { | 287 | const IR::Value& offset, std::string_view value) { |
| 282 | throw NotImplementedException("GLSL Instrucion"); | 288 | LOG_WARNING(Shader_GLSL, "Int64 atomics not supported, fallback to non-atomic"); |
| 289 | ctx.AddU32x2("{}=ivec2({}_ssbo{}[{}>>2],{}_ssbo{}[({}>>2)+1]);", inst, ctx.stage_name, | ||
| 290 | binding.U32(), ctx.var_alloc.Consume(offset), ctx.stage_name, binding.U32(), | ||
| 291 | ctx.var_alloc.Consume(offset)); | ||
| 292 | ctx.Add("for(int " | ||
| 293 | "i=0;i<2;++i){{{}_ssbo{}[({}>>2)+i]=uint(min(int({}_ssbo{}[({}>>2)+i]),int({}[i])));}}", | ||
| 294 | ctx.stage_name, binding.U32(), ctx.var_alloc.Consume(offset), ctx.stage_name, | ||
| 295 | binding.U32(), ctx.var_alloc.Consume(offset), value); | ||
| 283 | } | 296 | } |
| 284 | 297 | ||
| 285 | void EmitStorageAtomicUMin32x2(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, | 298 | void EmitStorageAtomicUMin32x2(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, |
| 286 | const IR::Value& offset, std::string_view value) { | 299 | const IR::Value& offset, std::string_view value) { |
| 287 | throw NotImplementedException("GLSL Instrucion"); | 300 | LOG_WARNING(Shader_GLSL, "Int64 atomics not supported, fallback to non-atomic"); |
| 301 | ctx.AddU32x2("{}=uvec2({}_ssbo{}[{}>>2],{}_ssbo{}[({}>>2)+1]);", inst, ctx.stage_name, | ||
| 302 | binding.U32(), ctx.var_alloc.Consume(offset), ctx.stage_name, binding.U32(), | ||
| 303 | ctx.var_alloc.Consume(offset)); | ||
| 304 | ctx.Add("for(int i=0;i<2;++i){{ " | ||
| 305 | "{}_ssbo{}[({}>>2)+i]=min({}_ssbo{}[({}>>2)+i],{}[i]);}}", | ||
| 306 | ctx.stage_name, binding.U32(), ctx.var_alloc.Consume(offset), ctx.stage_name, | ||
| 307 | binding.U32(), ctx.var_alloc.Consume(offset), value); | ||
| 288 | } | 308 | } |
| 289 | 309 | ||
| 290 | void EmitStorageAtomicSMax32x2(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, | 310 | void EmitStorageAtomicSMax32x2(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, |
| 291 | const IR::Value& offset, std::string_view value) { | 311 | const IR::Value& offset, std::string_view value) { |
| 292 | throw NotImplementedException("GLSL Instrucion"); | 312 | LOG_WARNING(Shader_GLSL, "Int64 atomics not supported, fallback to non-atomic"); |
| 313 | ctx.AddU32x2("{}=ivec2({}_ssbo{}[{}>>2],{}_ssbo{}[({}>>2)+1]);", inst, ctx.stage_name, | ||
| 314 | binding.U32(), ctx.var_alloc.Consume(offset), ctx.stage_name, binding.U32(), | ||
| 315 | ctx.var_alloc.Consume(offset)); | ||
| 316 | ctx.Add("for(int " | ||
| 317 | "i=0;i<2;++i){{{}_ssbo{}[({}>>2)+i]=uint(max(int({}_ssbo{}[({}>>2)+i]),int({}[i])));}}", | ||
| 318 | ctx.stage_name, binding.U32(), ctx.var_alloc.Consume(offset), ctx.stage_name, | ||
| 319 | binding.U32(), ctx.var_alloc.Consume(offset), value); | ||
| 293 | } | 320 | } |
| 294 | 321 | ||
| 295 | void EmitStorageAtomicUMax32x2(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, | 322 | void EmitStorageAtomicUMax32x2(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, |
| 296 | const IR::Value& offset, std::string_view value) { | 323 | const IR::Value& offset, std::string_view value) { |
| 297 | throw NotImplementedException("GLSL Instrucion"); | 324 | LOG_WARNING(Shader_GLSL, "Int64 atomics not supported, fallback to non-atomic"); |
| 325 | ctx.AddU32x2("{}=uvec2({}_ssbo{}[{}>>2],{}_ssbo{}[({}>>2)+1]);", inst, ctx.stage_name, | ||
| 326 | binding.U32(), ctx.var_alloc.Consume(offset), ctx.stage_name, binding.U32(), | ||
| 327 | ctx.var_alloc.Consume(offset)); | ||
| 328 | ctx.Add("for(int i=0;i<2;++i){{{}_ssbo{}[({}>>2)+i]=max({}_ssbo{}[({}>>2)+i],{}[i]);}}", | ||
| 329 | ctx.stage_name, binding.U32(), ctx.var_alloc.Consume(offset), ctx.stage_name, | ||
| 330 | binding.U32(), ctx.var_alloc.Consume(offset), value); | ||
| 298 | } | 331 | } |
| 299 | 332 | ||
| 300 | void EmitStorageAtomicAnd32x2(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, | 333 | void EmitStorageAtomicAnd32x2(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, |
| 301 | const IR::Value& offset, std::string_view value) { | 334 | const IR::Value& offset, std::string_view value) { |
| 302 | throw NotImplementedException("GLSL Instrucion"); | 335 | LOG_WARNING(Shader_GLSL, "Int64 atomics not supported, fallback to 32x2"); |
| 336 | ctx.AddU32x2("{}=uvec2(atomicAnd({}_ssbo{}[{}>>2],{}.x),atomicAnd({}_ssbo{}[({}>>2)+1],{}.y));", | ||
| 337 | inst, ctx.stage_name, binding.U32(), ctx.var_alloc.Consume(offset), value, | ||
| 338 | ctx.stage_name, binding.U32(), ctx.var_alloc.Consume(offset), value); | ||
| 303 | } | 339 | } |
| 304 | 340 | ||
| 305 | void EmitStorageAtomicOr32x2(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, | 341 | void EmitStorageAtomicOr32x2(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, |
| 306 | const IR::Value& offset, std::string_view value) { | 342 | const IR::Value& offset, std::string_view value) { |
| 307 | throw NotImplementedException("GLSL Instrucion"); | 343 | LOG_WARNING(Shader_GLSL, "Int64 atomics not supported, fallback to 32x2"); |
| 344 | ctx.AddU32x2("{}=uvec2(atomicOr({}_ssbo{}[{}>>2],{}.x),atomicOr({}_ssbo{}[({}>>2)+1],{}.y));", | ||
| 345 | inst, ctx.stage_name, binding.U32(), ctx.var_alloc.Consume(offset), value, | ||
| 346 | ctx.stage_name, binding.U32(), ctx.var_alloc.Consume(offset), value); | ||
| 308 | } | 347 | } |
| 309 | 348 | ||
| 310 | void EmitStorageAtomicXor32x2(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, | 349 | void EmitStorageAtomicXor32x2(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, |
| 311 | const IR::Value& offset, std::string_view value) { | 350 | const IR::Value& offset, std::string_view value) { |
| 312 | throw NotImplementedException("GLSL Instrucion"); | 351 | LOG_WARNING(Shader_GLSL, "Int64 atomics not supported, fallback to 32x2"); |
| 352 | ctx.AddU32x2("{}=uvec2(atomicXor({}_ssbo{}[{}>>2],{}.x),atomicXor({}_ssbo{}[({}>>2)+1],{}.y));", | ||
| 353 | inst, ctx.stage_name, binding.U32(), ctx.var_alloc.Consume(offset), value, | ||
| 354 | ctx.stage_name, binding.U32(), ctx.var_alloc.Consume(offset), value); | ||
| 313 | } | 355 | } |
| 314 | 356 | ||
| 315 | void EmitStorageAtomicExchange32x2(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, | 357 | void EmitStorageAtomicExchange32x2(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, |
| 316 | const IR::Value& offset, std::string_view value) { | 358 | const IR::Value& offset, std::string_view value) { |
| 317 | throw NotImplementedException("GLSL Instrucion"); | 359 | LOG_WARNING(Shader_GLSL, "Int64 atomics not supported, fallback to 32x2"); |
| 360 | ctx.AddU32x2("{}=uvec2(atomicExchange({}_ssbo{}[{}>>2],{}.x),atomicExchange({}_ssbo{}[({}>>2)+" | ||
| 361 | "1],{}.y));", | ||
| 362 | inst, ctx.stage_name, binding.U32(), ctx.var_alloc.Consume(offset), value, | ||
| 363 | ctx.stage_name, binding.U32(), ctx.var_alloc.Consume(offset), value); | ||
| 318 | } | 364 | } |
| 319 | 365 | ||
| 320 | void EmitStorageAtomicAddF32(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, | 366 | void EmitStorageAtomicAddF32(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, |