diff options
| author | 2021-06-10 00:29:19 -0400 | |
|---|---|---|
| committer | 2021-07-22 21:51:37 -0400 | |
| commit | 85399e119d6d61375fd9304d69bdfb3a85522d2a (patch) | |
| tree | 6b89d199c729ace799392a97268e228d81d9422e /src/shader_recompiler/backend/glsl/emit_glsl_image.cpp | |
| parent | glsl: Implement SampleId and SetSampleMask (diff) | |
| download | yuzu-85399e119d6d61375fd9304d69bdfb3a85522d2a.tar.gz yuzu-85399e119d6d61375fd9304d69bdfb3a85522d2a.tar.xz yuzu-85399e119d6d61375fd9304d69bdfb3a85522d2a.zip | |
glsl: Reorganize backend code, remove unneeded [[maybe_unused]]
Diffstat (limited to 'src/shader_recompiler/backend/glsl/emit_glsl_image.cpp')
| -rw-r--r-- | src/shader_recompiler/backend/glsl/emit_glsl_image.cpp | 170 |
1 files changed, 74 insertions, 96 deletions
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_image.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_image.cpp index e3a69e3a5..00fe288e2 100644 --- a/src/shader_recompiler/backend/glsl/emit_glsl_image.cpp +++ b/src/shader_recompiler/backend/glsl/emit_glsl_image.cpp | |||
| @@ -12,8 +12,7 @@ | |||
| 12 | 12 | ||
| 13 | namespace Shader::Backend::GLSL { | 13 | namespace Shader::Backend::GLSL { |
| 14 | namespace { | 14 | namespace { |
| 15 | std::string Texture(EmitContext& ctx, const IR::TextureInstInfo& info, | 15 | std::string Texture(EmitContext& ctx, const IR::TextureInstInfo& info) { |
| 16 | [[maybe_unused]] const IR::Value& index) { | ||
| 17 | if (info.type == TextureType::Buffer) { | 16 | if (info.type == TextureType::Buffer) { |
| 18 | return fmt::format("tex{}", ctx.texture_buffer_bindings.at(info.descriptor_index)); | 17 | return fmt::format("tex{}", ctx.texture_buffer_bindings.at(info.descriptor_index)); |
| 19 | } else { | 18 | } else { |
| @@ -21,8 +20,7 @@ std::string Texture(EmitContext& ctx, const IR::TextureInstInfo& info, | |||
| 21 | } | 20 | } |
| 22 | } | 21 | } |
| 23 | 22 | ||
| 24 | std::string Image(EmitContext& ctx, const IR::TextureInstInfo& info, | 23 | std::string Image(EmitContext& ctx, const IR::TextureInstInfo& info) { |
| 25 | [[maybe_unused]] const IR::Value& index) { | ||
| 26 | if (info.type == TextureType::Buffer) { | 24 | if (info.type == TextureType::Buffer) { |
| 27 | return fmt::format("img{}", ctx.image_buffer_bindings.at(info.descriptor_index)); | 25 | return fmt::format("img{}", ctx.image_buffer_bindings.at(info.descriptor_index)); |
| 28 | } else { | 26 | } else { |
| @@ -139,16 +137,14 @@ IR::Inst* PrepareSparse(IR::Inst& inst) { | |||
| 139 | } | 137 | } |
| 140 | } // Anonymous namespace | 138 | } // Anonymous namespace |
| 141 | 139 | ||
| 142 | void EmitImageSampleImplicitLod([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | 140 | void EmitImageSampleImplicitLod(EmitContext& ctx, IR::Inst& inst, |
| 143 | [[maybe_unused]] const IR::Value& index, | 141 | [[maybe_unused]] const IR::Value& index, std::string_view coords, |
| 144 | [[maybe_unused]] std::string_view coords, | 142 | std::string_view bias_lc, const IR::Value& offset) { |
| 145 | [[maybe_unused]] std::string_view bias_lc, | ||
| 146 | [[maybe_unused]] const IR::Value& offset) { | ||
| 147 | const auto info{inst.Flags<IR::TextureInstInfo>()}; | 143 | const auto info{inst.Flags<IR::TextureInstInfo>()}; |
| 148 | if (info.has_lod_clamp) { | 144 | if (info.has_lod_clamp) { |
| 149 | throw NotImplementedException("EmitImageSampleImplicitLod Lod clamp samples"); | 145 | throw NotImplementedException("EmitImageSampleImplicitLod Lod clamp samples"); |
| 150 | } | 146 | } |
| 151 | const auto texture{Texture(ctx, info, index)}; | 147 | const auto texture{Texture(ctx, info)}; |
| 152 | const auto bias{info.has_bias ? fmt::format(",{}", bias_lc) : ""}; | 148 | const auto bias{info.has_bias ? fmt::format(",{}", bias_lc) : ""}; |
| 153 | const auto texel{ctx.var_alloc.Define(inst, GlslVarType::F32x4)}; | 149 | const auto texel{ctx.var_alloc.Define(inst, GlslVarType::F32x4)}; |
| 154 | const auto sparse_inst{PrepareSparse(inst)}; | 150 | const auto sparse_inst{PrepareSparse(inst)}; |
| @@ -179,11 +175,9 @@ void EmitImageSampleImplicitLod([[maybe_unused]] EmitContext& ctx, [[maybe_unuse | |||
| 179 | } | 175 | } |
| 180 | } | 176 | } |
| 181 | 177 | ||
| 182 | void EmitImageSampleExplicitLod([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | 178 | void EmitImageSampleExplicitLod(EmitContext& ctx, IR::Inst& inst, |
| 183 | [[maybe_unused]] const IR::Value& index, | 179 | [[maybe_unused]] const IR::Value& index, std::string_view coords, |
| 184 | [[maybe_unused]] std::string_view coords, | 180 | std::string_view lod_lc, const IR::Value& offset) { |
| 185 | [[maybe_unused]] std::string_view lod_lc, | ||
| 186 | [[maybe_unused]] const IR::Value& offset) { | ||
| 187 | const auto info{inst.Flags<IR::TextureInstInfo>()}; | 181 | const auto info{inst.Flags<IR::TextureInstInfo>()}; |
| 188 | if (info.has_bias) { | 182 | if (info.has_bias) { |
| 189 | throw NotImplementedException("EmitImageSampleExplicitLod Bias texture samples"); | 183 | throw NotImplementedException("EmitImageSampleExplicitLod Bias texture samples"); |
| @@ -191,7 +185,7 @@ void EmitImageSampleExplicitLod([[maybe_unused]] EmitContext& ctx, [[maybe_unuse | |||
| 191 | if (info.has_lod_clamp) { | 185 | if (info.has_lod_clamp) { |
| 192 | throw NotImplementedException("EmitImageSampleExplicitLod Lod clamp samples"); | 186 | throw NotImplementedException("EmitImageSampleExplicitLod Lod clamp samples"); |
| 193 | } | 187 | } |
| 194 | const auto texture{Texture(ctx, info, index)}; | 188 | const auto texture{Texture(ctx, info)}; |
| 195 | const auto texel{ctx.var_alloc.Define(inst, GlslVarType::F32x4)}; | 189 | const auto texel{ctx.var_alloc.Define(inst, GlslVarType::F32x4)}; |
| 196 | const auto sparse_inst{PrepareSparse(inst)}; | 190 | const auto sparse_inst{PrepareSparse(inst)}; |
| 197 | if (!sparse_inst) { | 191 | if (!sparse_inst) { |
| @@ -214,13 +208,10 @@ void EmitImageSampleExplicitLod([[maybe_unused]] EmitContext& ctx, [[maybe_unuse | |||
| 214 | } | 208 | } |
| 215 | } | 209 | } |
| 216 | 210 | ||
| 217 | void EmitImageSampleDrefImplicitLod([[maybe_unused]] EmitContext& ctx, | 211 | void EmitImageSampleDrefImplicitLod(EmitContext& ctx, IR::Inst& inst, |
| 218 | [[maybe_unused]] IR::Inst& inst, | ||
| 219 | [[maybe_unused]] const IR::Value& index, | 212 | [[maybe_unused]] const IR::Value& index, |
| 220 | [[maybe_unused]] std::string_view coords, | 213 | std::string_view coords, std::string_view dref, |
| 221 | [[maybe_unused]] std::string_view dref, | 214 | std::string_view bias_lc, const IR::Value& offset) { |
| 222 | [[maybe_unused]] std::string_view bias_lc, | ||
| 223 | [[maybe_unused]] const IR::Value& offset) { | ||
| 224 | const auto info{inst.Flags<IR::TextureInstInfo>()}; | 215 | const auto info{inst.Flags<IR::TextureInstInfo>()}; |
| 225 | const auto sparse_inst{PrepareSparse(inst)}; | 216 | const auto sparse_inst{PrepareSparse(inst)}; |
| 226 | if (sparse_inst) { | 217 | if (sparse_inst) { |
| @@ -232,7 +223,7 @@ void EmitImageSampleDrefImplicitLod([[maybe_unused]] EmitContext& ctx, | |||
| 232 | if (info.has_lod_clamp) { | 223 | if (info.has_lod_clamp) { |
| 233 | throw NotImplementedException("EmitImageSampleDrefImplicitLod Lod clamp samples"); | 224 | throw NotImplementedException("EmitImageSampleDrefImplicitLod Lod clamp samples"); |
| 234 | } | 225 | } |
| 235 | const auto texture{Texture(ctx, info, index)}; | 226 | const auto texture{Texture(ctx, info)}; |
| 236 | const auto bias{info.has_bias ? fmt::format(",{}", bias_lc) : ""}; | 227 | const auto bias{info.has_bias ? fmt::format(",{}", bias_lc) : ""}; |
| 237 | const bool needs_shadow_ext{NeedsShadowLodExt(info.type)}; | 228 | const bool needs_shadow_ext{NeedsShadowLodExt(info.type)}; |
| 238 | const auto cast{needs_shadow_ext ? "vec4" : "vec3"}; | 229 | const auto cast{needs_shadow_ext ? "vec4" : "vec3"}; |
| @@ -272,13 +263,10 @@ void EmitImageSampleDrefImplicitLod([[maybe_unused]] EmitContext& ctx, | |||
| 272 | } | 263 | } |
| 273 | } | 264 | } |
| 274 | 265 | ||
| 275 | void EmitImageSampleDrefExplicitLod([[maybe_unused]] EmitContext& ctx, | 266 | void EmitImageSampleDrefExplicitLod(EmitContext& ctx, IR::Inst& inst, |
| 276 | [[maybe_unused]] IR::Inst& inst, | ||
| 277 | [[maybe_unused]] const IR::Value& index, | 267 | [[maybe_unused]] const IR::Value& index, |
| 278 | [[maybe_unused]] std::string_view coords, | 268 | std::string_view coords, std::string_view dref, |
| 279 | [[maybe_unused]] std::string_view dref, | 269 | std::string_view lod_lc, const IR::Value& offset) { |
| 280 | [[maybe_unused]] std::string_view lod_lc, | ||
| 281 | [[maybe_unused]] const IR::Value& offset) { | ||
| 282 | const auto info{inst.Flags<IR::TextureInstInfo>()}; | 270 | const auto info{inst.Flags<IR::TextureInstInfo>()}; |
| 283 | const auto sparse_inst{PrepareSparse(inst)}; | 271 | const auto sparse_inst{PrepareSparse(inst)}; |
| 284 | if (sparse_inst) { | 272 | if (sparse_inst) { |
| @@ -290,7 +278,7 @@ void EmitImageSampleDrefExplicitLod([[maybe_unused]] EmitContext& ctx, | |||
| 290 | if (info.has_lod_clamp) { | 278 | if (info.has_lod_clamp) { |
| 291 | throw NotImplementedException("EmitImageSampleDrefExplicitLod Lod clamp samples"); | 279 | throw NotImplementedException("EmitImageSampleDrefExplicitLod Lod clamp samples"); |
| 292 | } | 280 | } |
| 293 | const auto texture{Texture(ctx, info, index)}; | 281 | const auto texture{Texture(ctx, info)}; |
| 294 | const bool needs_shadow_ext{NeedsShadowLodExt(info.type)}; | 282 | const bool needs_shadow_ext{NeedsShadowLodExt(info.type)}; |
| 295 | const bool use_grad{!ctx.profile.support_gl_texture_shadow_lod && needs_shadow_ext}; | 283 | const bool use_grad{!ctx.profile.support_gl_texture_shadow_lod && needs_shadow_ext}; |
| 296 | const auto cast{needs_shadow_ext ? "vec4" : "vec3"}; | 284 | const auto cast{needs_shadow_ext ? "vec4" : "vec3"}; |
| @@ -325,13 +313,10 @@ void EmitImageSampleDrefExplicitLod([[maybe_unused]] EmitContext& ctx, | |||
| 325 | } | 313 | } |
| 326 | } | 314 | } |
| 327 | 315 | ||
| 328 | void EmitImageGather([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | 316 | void EmitImageGather(EmitContext& ctx, IR::Inst& inst, [[maybe_unused]] const IR::Value& index, |
| 329 | [[maybe_unused]] const IR::Value& index, | 317 | std::string_view coords, const IR::Value& offset, const IR::Value& offset2) { |
| 330 | [[maybe_unused]] std::string_view coords, | ||
| 331 | [[maybe_unused]] const IR::Value& offset, | ||
| 332 | [[maybe_unused]] const IR::Value& offset2) { | ||
| 333 | const auto info{inst.Flags<IR::TextureInstInfo>()}; | 318 | const auto info{inst.Flags<IR::TextureInstInfo>()}; |
| 334 | const auto texture{Texture(ctx, info, index)}; | 319 | const auto texture{Texture(ctx, info)}; |
| 335 | const auto texel{ctx.var_alloc.Define(inst, GlslVarType::F32x4)}; | 320 | const auto texel{ctx.var_alloc.Define(inst, GlslVarType::F32x4)}; |
| 336 | const auto sparse_inst{PrepareSparse(inst)}; | 321 | const auto sparse_inst{PrepareSparse(inst)}; |
| 337 | if (!sparse_inst) { | 322 | if (!sparse_inst) { |
| @@ -370,14 +355,11 @@ void EmitImageGather([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Ins | |||
| 370 | info.gather_component); | 355 | info.gather_component); |
| 371 | } | 356 | } |
| 372 | 357 | ||
| 373 | void EmitImageGatherDref([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | 358 | void EmitImageGatherDref(EmitContext& ctx, IR::Inst& inst, [[maybe_unused]] const IR::Value& index, |
| 374 | [[maybe_unused]] const IR::Value& index, | 359 | std::string_view coords, const IR::Value& offset, const IR::Value& offset2, |
| 375 | [[maybe_unused]] std::string_view coords, | 360 | std::string_view dref) { |
| 376 | [[maybe_unused]] const IR::Value& offset, | ||
| 377 | [[maybe_unused]] const IR::Value& offset2, | ||
| 378 | [[maybe_unused]] std::string_view dref) { | ||
| 379 | const auto info{inst.Flags<IR::TextureInstInfo>()}; | 361 | const auto info{inst.Flags<IR::TextureInstInfo>()}; |
| 380 | const auto texture{Texture(ctx, info, index)}; | 362 | const auto texture{Texture(ctx, info)}; |
| 381 | const auto texel{ctx.var_alloc.Define(inst, GlslVarType::F32x4)}; | 363 | const auto texel{ctx.var_alloc.Define(inst, GlslVarType::F32x4)}; |
| 382 | const auto sparse_inst{PrepareSparse(inst)}; | 364 | const auto sparse_inst{PrepareSparse(inst)}; |
| 383 | if (!sparse_inst) { | 365 | if (!sparse_inst) { |
| @@ -413,10 +395,8 @@ void EmitImageGatherDref([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR: | |||
| 413 | *sparse_inst, texture, CastToIntVec(coords, info), dref, offsets, texel); | 395 | *sparse_inst, texture, CastToIntVec(coords, info), dref, offsets, texel); |
| 414 | } | 396 | } |
| 415 | 397 | ||
| 416 | void EmitImageFetch([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | 398 | void EmitImageFetch(EmitContext& ctx, IR::Inst& inst, [[maybe_unused]] const IR::Value& index, |
| 417 | [[maybe_unused]] const IR::Value& index, | 399 | std::string_view coords, std::string_view offset, std::string_view lod, |
| 418 | [[maybe_unused]] std::string_view coords, | ||
| 419 | [[maybe_unused]] std::string_view offset, [[maybe_unused]] std::string_view lod, | ||
| 420 | [[maybe_unused]] std::string_view ms) { | 400 | [[maybe_unused]] std::string_view ms) { |
| 421 | const auto info{inst.Flags<IR::TextureInstInfo>()}; | 401 | const auto info{inst.Flags<IR::TextureInstInfo>()}; |
| 422 | if (info.has_bias) { | 402 | if (info.has_bias) { |
| @@ -425,7 +405,7 @@ void EmitImageFetch([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst | |||
| 425 | if (info.has_lod_clamp) { | 405 | if (info.has_lod_clamp) { |
| 426 | throw NotImplementedException("EmitImageFetch Lod clamp samples"); | 406 | throw NotImplementedException("EmitImageFetch Lod clamp samples"); |
| 427 | } | 407 | } |
| 428 | const auto texture{Texture(ctx, info, index)}; | 408 | const auto texture{Texture(ctx, info)}; |
| 429 | const auto sparse_inst{PrepareSparse(inst)}; | 409 | const auto sparse_inst{PrepareSparse(inst)}; |
| 430 | const auto texel{ctx.var_alloc.Define(inst, GlslVarType::F32x4)}; | 410 | const auto texel{ctx.var_alloc.Define(inst, GlslVarType::F32x4)}; |
| 431 | if (!sparse_inst) { | 411 | if (!sparse_inst) { |
| @@ -453,11 +433,10 @@ void EmitImageFetch([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst | |||
| 453 | } | 433 | } |
| 454 | } | 434 | } |
| 455 | 435 | ||
| 456 | void EmitImageQueryDimensions([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | 436 | void EmitImageQueryDimensions(EmitContext& ctx, IR::Inst& inst, |
| 457 | [[maybe_unused]] const IR::Value& index, | 437 | [[maybe_unused]] const IR::Value& index, std::string_view lod) { |
| 458 | [[maybe_unused]] std::string_view lod) { | ||
| 459 | const auto info{inst.Flags<IR::TextureInstInfo>()}; | 438 | const auto info{inst.Flags<IR::TextureInstInfo>()}; |
| 460 | const auto texture{Texture(ctx, info, index)}; | 439 | const auto texture{Texture(ctx, info)}; |
| 461 | switch (info.type) { | 440 | switch (info.type) { |
| 462 | case TextureType::Color1D: | 441 | case TextureType::Color1D: |
| 463 | return ctx.AddU32x4( | 442 | return ctx.AddU32x4( |
| @@ -481,20 +460,16 @@ void EmitImageQueryDimensions([[maybe_unused]] EmitContext& ctx, [[maybe_unused] | |||
| 481 | throw LogicError("Unspecified image type {}", info.type.Value()); | 460 | throw LogicError("Unspecified image type {}", info.type.Value()); |
| 482 | } | 461 | } |
| 483 | 462 | ||
| 484 | void EmitImageQueryLod([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | 463 | void EmitImageQueryLod(EmitContext& ctx, IR::Inst& inst, [[maybe_unused]] const IR::Value& index, |
| 485 | [[maybe_unused]] const IR::Value& index, | 464 | std::string_view coords) { |
| 486 | [[maybe_unused]] std::string_view coords) { | ||
| 487 | const auto info{inst.Flags<IR::TextureInstInfo>()}; | 465 | const auto info{inst.Flags<IR::TextureInstInfo>()}; |
| 488 | const auto texture{Texture(ctx, info, index)}; | 466 | const auto texture{Texture(ctx, info)}; |
| 489 | return ctx.AddF32x4("{}=vec4(textureQueryLod({},{}),0.0,0.0);", inst, texture, coords); | 467 | return ctx.AddF32x4("{}=vec4(textureQueryLod({},{}),0.0,0.0);", inst, texture, coords); |
| 490 | } | 468 | } |
| 491 | 469 | ||
| 492 | void EmitImageGradient([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | 470 | void EmitImageGradient(EmitContext& ctx, IR::Inst& inst, [[maybe_unused]] const IR::Value& index, |
| 493 | [[maybe_unused]] const IR::Value& index, | 471 | std::string_view coords, const IR::Value& derivatives, |
| 494 | [[maybe_unused]] std::string_view coords, | 472 | const IR::Value& offset, [[maybe_unused]] const IR::Value& lod_clamp) { |
| 495 | [[maybe_unused]] const IR::Value& derivatives, | ||
| 496 | [[maybe_unused]] const IR::Value& offset, | ||
| 497 | [[maybe_unused]] const IR::Value& lod_clamp) { | ||
| 498 | const auto info{inst.Flags<IR::TextureInstInfo>()}; | 473 | const auto info{inst.Flags<IR::TextureInstInfo>()}; |
| 499 | if (info.has_lod_clamp) { | 474 | if (info.has_lod_clamp) { |
| 500 | throw NotImplementedException("EmitImageGradient Lod clamp samples"); | 475 | throw NotImplementedException("EmitImageGradient Lod clamp samples"); |
| @@ -506,7 +481,7 @@ void EmitImageGradient([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::I | |||
| 506 | if (!offset.IsEmpty()) { | 481 | if (!offset.IsEmpty()) { |
| 507 | throw NotImplementedException("EmitImageGradient offset"); | 482 | throw NotImplementedException("EmitImageGradient offset"); |
| 508 | } | 483 | } |
| 509 | const auto texture{Texture(ctx, info, index)}; | 484 | const auto texture{Texture(ctx, info)}; |
| 510 | const auto texel{ctx.var_alloc.Define(inst, GlslVarType::F32x4)}; | 485 | const auto texel{ctx.var_alloc.Define(inst, GlslVarType::F32x4)}; |
| 511 | const bool multi_component{info.num_derivates > 1 || info.has_lod_clamp}; | 486 | const bool multi_component{info.num_derivates > 1 || info.has_lod_clamp}; |
| 512 | const auto derivatives_vec{ctx.var_alloc.Consume(derivatives)}; | 487 | const auto derivatives_vec{ctx.var_alloc.Consume(derivatives)}; |
| @@ -519,63 +494,65 @@ void EmitImageGradient([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::I | |||
| 519 | } | 494 | } |
| 520 | } | 495 | } |
| 521 | 496 | ||
| 522 | void EmitImageRead([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | 497 | void EmitImageRead(EmitContext& ctx, IR::Inst& inst, [[maybe_unused]] const IR::Value& index, |
| 523 | [[maybe_unused]] const IR::Value& index, | 498 | std::string_view coords) { |
| 524 | [[maybe_unused]] std::string_view coords) { | ||
| 525 | const auto info{inst.Flags<IR::TextureInstInfo>()}; | 499 | const auto info{inst.Flags<IR::TextureInstInfo>()}; |
| 526 | const auto sparse_inst{PrepareSparse(inst)}; | 500 | const auto sparse_inst{PrepareSparse(inst)}; |
| 527 | if (sparse_inst) { | 501 | if (sparse_inst) { |
| 528 | throw NotImplementedException("EmitImageRead Sparse"); | 502 | throw NotImplementedException("EmitImageRead Sparse"); |
| 529 | } | 503 | } |
| 530 | const auto image{Image(ctx, info, index)}; | 504 | const auto image{Image(ctx, info)}; |
| 531 | ctx.AddU32x4("{}=uvec4(imageLoad({},{}));", inst, image, TexelFetchCastToInt(coords, info)); | 505 | ctx.AddU32x4("{}=uvec4(imageLoad({},{}));", inst, image, TexelFetchCastToInt(coords, info)); |
| 532 | } | 506 | } |
| 533 | 507 | ||
| 534 | void EmitImageWrite([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | 508 | void EmitImageWrite(EmitContext& ctx, IR::Inst& inst, [[maybe_unused]] const IR::Value& index, |
| 535 | [[maybe_unused]] const IR::Value& index, | 509 | std::string_view coords, std::string_view color) { |
| 536 | [[maybe_unused]] std::string_view coords, | ||
| 537 | [[maybe_unused]] std::string_view color) { | ||
| 538 | const auto info{inst.Flags<IR::TextureInstInfo>()}; | 510 | const auto info{inst.Flags<IR::TextureInstInfo>()}; |
| 539 | const auto image{Image(ctx, info, index)}; | 511 | const auto image{Image(ctx, info)}; |
| 540 | ctx.Add("imageStore({},{},{});", image, TexelFetchCastToInt(coords, info), color); | 512 | ctx.Add("imageStore({},{},{});", image, TexelFetchCastToInt(coords, info), color); |
| 541 | } | 513 | } |
| 542 | 514 | ||
| 543 | void EmitImageAtomicIAdd32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, | 515 | void EmitImageAtomicIAdd32(EmitContext& ctx, IR::Inst& inst, |
| 544 | std::string_view coords, std::string_view value) { | 516 | [[maybe_unused]] const IR::Value& index, std::string_view coords, |
| 517 | std::string_view value) { | ||
| 545 | const auto info{inst.Flags<IR::TextureInstInfo>()}; | 518 | const auto info{inst.Flags<IR::TextureInstInfo>()}; |
| 546 | const auto image{Image(ctx, info, index)}; | 519 | const auto image{Image(ctx, info)}; |
| 547 | ctx.AddU32("{}=imageAtomicAdd({},{},{});", inst, image, TexelFetchCastToInt(coords, info), | 520 | ctx.AddU32("{}=imageAtomicAdd({},{},{});", inst, image, TexelFetchCastToInt(coords, info), |
| 548 | value); | 521 | value); |
| 549 | } | 522 | } |
| 550 | 523 | ||
| 551 | void EmitImageAtomicSMin32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, | 524 | void EmitImageAtomicSMin32(EmitContext& ctx, IR::Inst& inst, |
| 552 | std::string_view coords, std::string_view value) { | 525 | [[maybe_unused]] const IR::Value& index, std::string_view coords, |
| 526 | std::string_view value) { | ||
| 553 | const auto info{inst.Flags<IR::TextureInstInfo>()}; | 527 | const auto info{inst.Flags<IR::TextureInstInfo>()}; |
| 554 | const auto image{Image(ctx, info, index)}; | 528 | const auto image{Image(ctx, info)}; |
| 555 | ctx.AddU32("{}=imageAtomicMin({},{},int({}));", inst, image, TexelFetchCastToInt(coords, info), | 529 | ctx.AddU32("{}=imageAtomicMin({},{},int({}));", inst, image, TexelFetchCastToInt(coords, info), |
| 556 | value); | 530 | value); |
| 557 | } | 531 | } |
| 558 | 532 | ||
| 559 | void EmitImageAtomicUMin32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, | 533 | void EmitImageAtomicUMin32(EmitContext& ctx, IR::Inst& inst, |
| 560 | std::string_view coords, std::string_view value) { | 534 | [[maybe_unused]] const IR::Value& index, std::string_view coords, |
| 535 | std::string_view value) { | ||
| 561 | const auto info{inst.Flags<IR::TextureInstInfo>()}; | 536 | const auto info{inst.Flags<IR::TextureInstInfo>()}; |
| 562 | const auto image{Image(ctx, info, index)}; | 537 | const auto image{Image(ctx, info)}; |
| 563 | ctx.AddU32("{}=imageAtomicMin({},{},uint({}));", inst, image, TexelFetchCastToInt(coords, info), | 538 | ctx.AddU32("{}=imageAtomicMin({},{},uint({}));", inst, image, TexelFetchCastToInt(coords, info), |
| 564 | value); | 539 | value); |
| 565 | } | 540 | } |
| 566 | 541 | ||
| 567 | void EmitImageAtomicSMax32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, | 542 | void EmitImageAtomicSMax32(EmitContext& ctx, IR::Inst& inst, |
| 568 | std::string_view coords, std::string_view value) { | 543 | [[maybe_unused]] const IR::Value& index, std::string_view coords, |
| 544 | std::string_view value) { | ||
| 569 | const auto info{inst.Flags<IR::TextureInstInfo>()}; | 545 | const auto info{inst.Flags<IR::TextureInstInfo>()}; |
| 570 | const auto image{Image(ctx, info, index)}; | 546 | const auto image{Image(ctx, info)}; |
| 571 | ctx.AddU32("{}=imageAtomicMax({},{},int({}));", inst, image, TexelFetchCastToInt(coords, info), | 547 | ctx.AddU32("{}=imageAtomicMax({},{},int({}));", inst, image, TexelFetchCastToInt(coords, info), |
| 572 | value); | 548 | value); |
| 573 | } | 549 | } |
| 574 | 550 | ||
| 575 | void EmitImageAtomicUMax32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, | 551 | void EmitImageAtomicUMax32(EmitContext& ctx, IR::Inst& inst, |
| 576 | std::string_view coords, std::string_view value) { | 552 | [[maybe_unused]] const IR::Value& index, std::string_view coords, |
| 553 | std::string_view value) { | ||
| 577 | const auto info{inst.Flags<IR::TextureInstInfo>()}; | 554 | const auto info{inst.Flags<IR::TextureInstInfo>()}; |
| 578 | const auto image{Image(ctx, info, index)}; | 555 | const auto image{Image(ctx, info)}; |
| 579 | ctx.AddU32("{}=imageAtomicMax({},{},uint({}));", inst, image, TexelFetchCastToInt(coords, info), | 556 | ctx.AddU32("{}=imageAtomicMax({},{},uint({}));", inst, image, TexelFetchCastToInt(coords, info), |
| 580 | value); | 557 | value); |
| 581 | } | 558 | } |
| @@ -590,34 +567,35 @@ void EmitImageAtomicDec32(EmitContext&, IR::Inst&, const IR::Value&, std::string | |||
| 590 | NotImplemented(); | 567 | NotImplemented(); |
| 591 | } | 568 | } |
| 592 | 569 | ||
| 593 | void EmitImageAtomicAnd32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, | 570 | void EmitImageAtomicAnd32(EmitContext& ctx, IR::Inst& inst, [[maybe_unused]] const IR::Value& index, |
| 594 | std::string_view coords, std::string_view value) { | 571 | std::string_view coords, std::string_view value) { |
| 595 | const auto info{inst.Flags<IR::TextureInstInfo>()}; | 572 | const auto info{inst.Flags<IR::TextureInstInfo>()}; |
| 596 | const auto image{Image(ctx, info, index)}; | 573 | const auto image{Image(ctx, info)}; |
| 597 | ctx.AddU32("{}=imageAtomicAnd({},{},{});", inst, image, TexelFetchCastToInt(coords, info), | 574 | ctx.AddU32("{}=imageAtomicAnd({},{},{});", inst, image, TexelFetchCastToInt(coords, info), |
| 598 | value); | 575 | value); |
| 599 | } | 576 | } |
| 600 | 577 | ||
| 601 | void EmitImageAtomicOr32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, | 578 | void EmitImageAtomicOr32(EmitContext& ctx, IR::Inst& inst, [[maybe_unused]] const IR::Value& index, |
| 602 | std::string_view coords, std::string_view value) { | 579 | std::string_view coords, std::string_view value) { |
| 603 | const auto info{inst.Flags<IR::TextureInstInfo>()}; | 580 | const auto info{inst.Flags<IR::TextureInstInfo>()}; |
| 604 | const auto image{Image(ctx, info, index)}; | 581 | const auto image{Image(ctx, info)}; |
| 605 | ctx.AddU32("{}=imageAtomicOr({},{},{});", inst, image, TexelFetchCastToInt(coords, info), | 582 | ctx.AddU32("{}=imageAtomicOr({},{},{});", inst, image, TexelFetchCastToInt(coords, info), |
| 606 | value); | 583 | value); |
| 607 | } | 584 | } |
| 608 | 585 | ||
| 609 | void EmitImageAtomicXor32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, | 586 | void EmitImageAtomicXor32(EmitContext& ctx, IR::Inst& inst, [[maybe_unused]] const IR::Value& index, |
| 610 | std::string_view coords, std::string_view value) { | 587 | std::string_view coords, std::string_view value) { |
| 611 | const auto info{inst.Flags<IR::TextureInstInfo>()}; | 588 | const auto info{inst.Flags<IR::TextureInstInfo>()}; |
| 612 | const auto image{Image(ctx, info, index)}; | 589 | const auto image{Image(ctx, info)}; |
| 613 | ctx.AddU32("{}=imageAtomicXor({},{},{});", inst, image, TexelFetchCastToInt(coords, info), | 590 | ctx.AddU32("{}=imageAtomicXor({},{},{});", inst, image, TexelFetchCastToInt(coords, info), |
| 614 | value); | 591 | value); |
| 615 | } | 592 | } |
| 616 | 593 | ||
| 617 | void EmitImageAtomicExchange32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, | 594 | void EmitImageAtomicExchange32(EmitContext& ctx, IR::Inst& inst, |
| 618 | std::string_view coords, std::string_view value) { | 595 | [[maybe_unused]] const IR::Value& index, std::string_view coords, |
| 596 | std::string_view value) { | ||
| 619 | const auto info{inst.Flags<IR::TextureInstInfo>()}; | 597 | const auto info{inst.Flags<IR::TextureInstInfo>()}; |
| 620 | const auto image{Image(ctx, info, index)}; | 598 | const auto image{Image(ctx, info)}; |
| 621 | ctx.AddU32("{}=imageAtomicExchange({},{},{});", inst, image, TexelFetchCastToInt(coords, info), | 599 | ctx.AddU32("{}=imageAtomicExchange({},{},{});", inst, image, TexelFetchCastToInt(coords, info), |
| 622 | value); | 600 | value); |
| 623 | } | 601 | } |