diff options
Diffstat (limited to 'src/shader_recompiler/backend/glsl/emit_glsl_image.cpp')
| -rw-r--r-- | src/shader_recompiler/backend/glsl/emit_glsl_image.cpp | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_image.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_image.cpp index 6a98f7ac2..51181d1c1 100644 --- a/src/shader_recompiler/backend/glsl/emit_glsl_image.cpp +++ b/src/shader_recompiler/backend/glsl/emit_glsl_image.cpp | |||
| @@ -45,7 +45,7 @@ std::string CastToIntVec(std::string_view value, const IR::TextureInstInfo& info | |||
| 45 | } | 45 | } |
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | std::string TexelFetchCastToInt(std::string_view value, const IR::TextureInstInfo& info) { | 48 | std::string CoordsCastToInt(std::string_view value, const IR::TextureInstInfo& info) { |
| 49 | switch (info.type) { | 49 | switch (info.type) { |
| 50 | case TextureType::Color1D: | 50 | case TextureType::Color1D: |
| 51 | case TextureType::Buffer: | 51 | case TextureType::Buffer: |
| @@ -407,13 +407,13 @@ void EmitImageFetch(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, | |||
| 407 | if (!sparse_inst) { | 407 | if (!sparse_inst) { |
| 408 | if (!offset.empty()) { | 408 | if (!offset.empty()) { |
| 409 | ctx.Add("{}=texelFetchOffset({},{},int({}),{});", texel, texture, | 409 | ctx.Add("{}=texelFetchOffset({},{},int({}),{});", texel, texture, |
| 410 | TexelFetchCastToInt(coords, info), lod, TexelFetchCastToInt(offset, info)); | 410 | CoordsCastToInt(coords, info), lod, CoordsCastToInt(offset, info)); |
| 411 | } else { | 411 | } else { |
| 412 | if (info.type == TextureType::Buffer) { | 412 | if (info.type == TextureType::Buffer) { |
| 413 | ctx.Add("{}=texelFetch({},int({}));", texel, texture, coords); | 413 | ctx.Add("{}=texelFetch({},int({}));", texel, texture, coords); |
| 414 | } else { | 414 | } else { |
| 415 | ctx.Add("{}=texelFetch({},{},int({}));", texel, texture, | 415 | ctx.Add("{}=texelFetch({},{},int({}));", texel, texture, |
| 416 | TexelFetchCastToInt(coords, info), lod); | 416 | CoordsCastToInt(coords, info), lod); |
| 417 | } | 417 | } |
| 418 | } | 418 | } |
| 419 | return; | 419 | return; |
| @@ -498,29 +498,28 @@ void EmitImageRead(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, | |||
| 498 | throw NotImplementedException("EmitImageRead Sparse"); | 498 | throw NotImplementedException("EmitImageRead Sparse"); |
| 499 | } | 499 | } |
| 500 | const auto image{Image(ctx, info, index)}; | 500 | const auto image{Image(ctx, info, index)}; |
| 501 | ctx.AddU32x4("{}=uvec4(imageLoad({},{}));", inst, image, TexelFetchCastToInt(coords, info)); | 501 | ctx.AddU32x4("{}=uvec4(imageLoad({},{}));", inst, image, CoordsCastToInt(coords, info)); |
| 502 | } | 502 | } |
| 503 | 503 | ||
| 504 | void EmitImageWrite(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, | 504 | void EmitImageWrite(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, |
| 505 | std::string_view coords, std::string_view color) { | 505 | std::string_view coords, std::string_view color) { |
| 506 | const auto info{inst.Flags<IR::TextureInstInfo>()}; | 506 | const auto info{inst.Flags<IR::TextureInstInfo>()}; |
| 507 | const auto image{Image(ctx, info, index)}; | 507 | const auto image{Image(ctx, info, index)}; |
| 508 | ctx.Add("imageStore({},{},{});", image, TexelFetchCastToInt(coords, info), color); | 508 | ctx.Add("imageStore({},{},{});", image, CoordsCastToInt(coords, info), color); |
| 509 | } | 509 | } |
| 510 | 510 | ||
| 511 | void EmitImageAtomicIAdd32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, | 511 | void EmitImageAtomicIAdd32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, |
| 512 | std::string_view coords, std::string_view value) { | 512 | std::string_view coords, std::string_view value) { |
| 513 | const auto info{inst.Flags<IR::TextureInstInfo>()}; | 513 | const auto info{inst.Flags<IR::TextureInstInfo>()}; |
| 514 | const auto image{Image(ctx, info, index)}; | 514 | const auto image{Image(ctx, info, index)}; |
| 515 | ctx.AddU32("{}=imageAtomicAdd({},{},{});", inst, image, TexelFetchCastToInt(coords, info), | 515 | ctx.AddU32("{}=imageAtomicAdd({},{},{});", inst, image, CoordsCastToInt(coords, info), value); |
| 516 | value); | ||
| 517 | } | 516 | } |
| 518 | 517 | ||
| 519 | void EmitImageAtomicSMin32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, | 518 | void EmitImageAtomicSMin32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, |
| 520 | std::string_view coords, std::string_view value) { | 519 | std::string_view coords, std::string_view value) { |
| 521 | const auto info{inst.Flags<IR::TextureInstInfo>()}; | 520 | const auto info{inst.Flags<IR::TextureInstInfo>()}; |
| 522 | const auto image{Image(ctx, info, index)}; | 521 | const auto image{Image(ctx, info, index)}; |
| 523 | ctx.AddU32("{}=imageAtomicMin({},{},int({}));", inst, image, TexelFetchCastToInt(coords, info), | 522 | ctx.AddU32("{}=imageAtomicMin({},{},int({}));", inst, image, CoordsCastToInt(coords, info), |
| 524 | value); | 523 | value); |
| 525 | } | 524 | } |
| 526 | 525 | ||
| @@ -528,7 +527,7 @@ void EmitImageAtomicUMin32(EmitContext& ctx, IR::Inst& inst, const IR::Value& in | |||
| 528 | std::string_view coords, std::string_view value) { | 527 | std::string_view coords, std::string_view value) { |
| 529 | const auto info{inst.Flags<IR::TextureInstInfo>()}; | 528 | const auto info{inst.Flags<IR::TextureInstInfo>()}; |
| 530 | const auto image{Image(ctx, info, index)}; | 529 | const auto image{Image(ctx, info, index)}; |
| 531 | ctx.AddU32("{}=imageAtomicMin({},{},uint({}));", inst, image, TexelFetchCastToInt(coords, info), | 530 | ctx.AddU32("{}=imageAtomicMin({},{},uint({}));", inst, image, CoordsCastToInt(coords, info), |
| 532 | value); | 531 | value); |
| 533 | } | 532 | } |
| 534 | 533 | ||
| @@ -536,7 +535,7 @@ void EmitImageAtomicSMax32(EmitContext& ctx, IR::Inst& inst, const IR::Value& in | |||
| 536 | std::string_view coords, std::string_view value) { | 535 | std::string_view coords, std::string_view value) { |
| 537 | const auto info{inst.Flags<IR::TextureInstInfo>()}; | 536 | const auto info{inst.Flags<IR::TextureInstInfo>()}; |
| 538 | const auto image{Image(ctx, info, index)}; | 537 | const auto image{Image(ctx, info, index)}; |
| 539 | ctx.AddU32("{}=imageAtomicMax({},{},int({}));", inst, image, TexelFetchCastToInt(coords, info), | 538 | ctx.AddU32("{}=imageAtomicMax({},{},int({}));", inst, image, CoordsCastToInt(coords, info), |
| 540 | value); | 539 | value); |
| 541 | } | 540 | } |
| 542 | 541 | ||
| @@ -544,7 +543,7 @@ void EmitImageAtomicUMax32(EmitContext& ctx, IR::Inst& inst, const IR::Value& in | |||
| 544 | std::string_view coords, std::string_view value) { | 543 | std::string_view coords, std::string_view value) { |
| 545 | const auto info{inst.Flags<IR::TextureInstInfo>()}; | 544 | const auto info{inst.Flags<IR::TextureInstInfo>()}; |
| 546 | const auto image{Image(ctx, info, index)}; | 545 | const auto image{Image(ctx, info, index)}; |
| 547 | ctx.AddU32("{}=imageAtomicMax({},{},uint({}));", inst, image, TexelFetchCastToInt(coords, info), | 546 | ctx.AddU32("{}=imageAtomicMax({},{},uint({}));", inst, image, CoordsCastToInt(coords, info), |
| 548 | value); | 547 | value); |
| 549 | } | 548 | } |
| 550 | 549 | ||
| @@ -562,31 +561,28 @@ void EmitImageAtomicAnd32(EmitContext& ctx, IR::Inst& inst, const IR::Value& ind | |||
| 562 | std::string_view coords, std::string_view value) { | 561 | std::string_view coords, std::string_view value) { |
| 563 | const auto info{inst.Flags<IR::TextureInstInfo>()}; | 562 | const auto info{inst.Flags<IR::TextureInstInfo>()}; |
| 564 | const auto image{Image(ctx, info, index)}; | 563 | const auto image{Image(ctx, info, index)}; |
| 565 | ctx.AddU32("{}=imageAtomicAnd({},{},{});", inst, image, TexelFetchCastToInt(coords, info), | 564 | ctx.AddU32("{}=imageAtomicAnd({},{},{});", inst, image, CoordsCastToInt(coords, info), value); |
| 566 | value); | ||
| 567 | } | 565 | } |
| 568 | 566 | ||
| 569 | void EmitImageAtomicOr32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, | 567 | void EmitImageAtomicOr32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, |
| 570 | std::string_view coords, std::string_view value) { | 568 | std::string_view coords, std::string_view value) { |
| 571 | const auto info{inst.Flags<IR::TextureInstInfo>()}; | 569 | const auto info{inst.Flags<IR::TextureInstInfo>()}; |
| 572 | const auto image{Image(ctx, info, index)}; | 570 | const auto image{Image(ctx, info, index)}; |
| 573 | ctx.AddU32("{}=imageAtomicOr({},{},{});", inst, image, TexelFetchCastToInt(coords, info), | 571 | ctx.AddU32("{}=imageAtomicOr({},{},{});", inst, image, CoordsCastToInt(coords, info), value); |
| 574 | value); | ||
| 575 | } | 572 | } |
| 576 | 573 | ||
| 577 | void EmitImageAtomicXor32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, | 574 | void EmitImageAtomicXor32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, |
| 578 | std::string_view coords, std::string_view value) { | 575 | std::string_view coords, std::string_view value) { |
| 579 | const auto info{inst.Flags<IR::TextureInstInfo>()}; | 576 | const auto info{inst.Flags<IR::TextureInstInfo>()}; |
| 580 | const auto image{Image(ctx, info, index)}; | 577 | const auto image{Image(ctx, info, index)}; |
| 581 | ctx.AddU32("{}=imageAtomicXor({},{},{});", inst, image, TexelFetchCastToInt(coords, info), | 578 | ctx.AddU32("{}=imageAtomicXor({},{},{});", inst, image, CoordsCastToInt(coords, info), value); |
| 582 | value); | ||
| 583 | } | 579 | } |
| 584 | 580 | ||
| 585 | void EmitImageAtomicExchange32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, | 581 | void EmitImageAtomicExchange32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, |
| 586 | std::string_view coords, std::string_view value) { | 582 | std::string_view coords, std::string_view value) { |
| 587 | const auto info{inst.Flags<IR::TextureInstInfo>()}; | 583 | const auto info{inst.Flags<IR::TextureInstInfo>()}; |
| 588 | const auto image{Image(ctx, info, index)}; | 584 | const auto image{Image(ctx, info, index)}; |
| 589 | ctx.AddU32("{}=imageAtomicExchange({},{},{});", inst, image, TexelFetchCastToInt(coords, info), | 585 | ctx.AddU32("{}=imageAtomicExchange({},{},{});", inst, image, CoordsCastToInt(coords, info), |
| 590 | value); | 586 | value); |
| 591 | } | 587 | } |
| 592 | 588 | ||