diff options
| author | 2021-05-25 20:54:34 -0400 | |
|---|---|---|
| committer | 2021-07-22 21:51:36 -0400 | |
| commit | 67f881e714ca5bd75c7f19f33e4d80352fad57c1 (patch) | |
| tree | e6a62d09cc021a17bfbcc9f4c07bb4093317ece1 /src/shader_recompiler/backend | |
| parent | glsl: Query GL Device for FP16 extension support (diff) | |
| download | yuzu-67f881e714ca5bd75c7f19f33e4d80352fad57c1.tar.gz yuzu-67f881e714ca5bd75c7f19f33e4d80352fad57c1.tar.xz yuzu-67f881e714ca5bd75c7f19f33e4d80352fad57c1.zip | |
glsl: Fix floating point compare ops
Logic for ordered/unordered ops was wrong.
Diffstat (limited to 'src/shader_recompiler/backend')
| -rw-r--r-- | src/shader_recompiler/backend/glsl/emit_glsl_floating_point.cpp | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_floating_point.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_floating_point.cpp index 665fc1562..f3d1d1af0 100644 --- a/src/shader_recompiler/backend/glsl/emit_glsl_floating_point.cpp +++ b/src/shader_recompiler/backend/glsl/emit_glsl_floating_point.cpp | |||
| @@ -12,12 +12,12 @@ | |||
| 12 | namespace Shader::Backend::GLSL { | 12 | namespace Shader::Backend::GLSL { |
| 13 | namespace { | 13 | namespace { |
| 14 | void Compare(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, std::string_view rhs, | 14 | void Compare(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, std::string_view rhs, |
| 15 | std::string_view op, std::string_view, bool ordered, bool inequality = false) { | 15 | std::string_view op, bool ordered) { |
| 16 | ctx.AddU1("{}={}{}{}", inst, lhs, op, rhs, lhs, rhs); | 16 | ctx.AddU1("{}={}{}{}", inst, lhs, op, rhs, lhs, rhs); |
| 17 | if (ordered && inequality) { | 17 | if (ordered) { |
| 18 | ctx.code += fmt::format("&&!isnan({})&&!isnan({})", lhs, rhs); | 18 | ctx.code += fmt::format("&&!isnan({})&&!isnan({})", lhs, rhs); |
| 19 | } else if (!ordered && !inequality) { | 19 | } else { |
| 20 | ctx.code += fmt::format("||!isnan({})||!isnan({})", lhs, rhs); | 20 | ctx.code += fmt::format("||isnan({})||isnan({})", lhs, rhs); |
| 21 | } | 21 | } |
| 22 | ctx.code += ";"; | 22 | ctx.code += ";"; |
| 23 | } | 23 | } |
| @@ -236,12 +236,12 @@ void EmitFPOrdEqual16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::s | |||
| 236 | 236 | ||
| 237 | void EmitFPOrdEqual32(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, | 237 | void EmitFPOrdEqual32(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, |
| 238 | std::string_view rhs) { | 238 | std::string_view rhs) { |
| 239 | Compare(ctx, inst, lhs, rhs, "==", "F", true); | 239 | Compare(ctx, inst, lhs, rhs, "==", true); |
| 240 | } | 240 | } |
| 241 | 241 | ||
| 242 | void EmitFPOrdEqual64(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, | 242 | void EmitFPOrdEqual64(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, |
| 243 | std::string_view rhs) { | 243 | std::string_view rhs) { |
| 244 | Compare(ctx, inst, lhs, rhs, "==", "F64", true); | 244 | Compare(ctx, inst, lhs, rhs, "==", true); |
| 245 | } | 245 | } |
| 246 | 246 | ||
| 247 | void EmitFPUnordEqual16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view lhs, | 247 | void EmitFPUnordEqual16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view lhs, |
| @@ -251,12 +251,12 @@ void EmitFPUnordEqual16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std: | |||
| 251 | 251 | ||
| 252 | void EmitFPUnordEqual32(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, | 252 | void EmitFPUnordEqual32(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, |
| 253 | std::string_view rhs) { | 253 | std::string_view rhs) { |
| 254 | Compare(ctx, inst, lhs, rhs, "==", "F", false); | 254 | Compare(ctx, inst, lhs, rhs, "==", false); |
| 255 | } | 255 | } |
| 256 | 256 | ||
| 257 | void EmitFPUnordEqual64(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, | 257 | void EmitFPUnordEqual64(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, |
| 258 | std::string_view rhs) { | 258 | std::string_view rhs) { |
| 259 | Compare(ctx, inst, lhs, rhs, "==", "F64", false); | 259 | Compare(ctx, inst, lhs, rhs, "==", false); |
| 260 | } | 260 | } |
| 261 | 261 | ||
| 262 | void EmitFPOrdNotEqual16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view lhs, | 262 | void EmitFPOrdNotEqual16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view lhs, |
| @@ -266,12 +266,12 @@ void EmitFPOrdNotEqual16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std | |||
| 266 | 266 | ||
| 267 | void EmitFPOrdNotEqual32(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, | 267 | void EmitFPOrdNotEqual32(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, |
| 268 | std::string_view rhs) { | 268 | std::string_view rhs) { |
| 269 | Compare(ctx, inst, lhs, rhs, "!=", "F", true, true); | 269 | Compare(ctx, inst, lhs, rhs, "!=", true); |
| 270 | } | 270 | } |
| 271 | 271 | ||
| 272 | void EmitFPOrdNotEqual64(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, | 272 | void EmitFPOrdNotEqual64(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, |
| 273 | std::string_view rhs) { | 273 | std::string_view rhs) { |
| 274 | Compare(ctx, inst, lhs, rhs, "!=", "F64", true, true); | 274 | Compare(ctx, inst, lhs, rhs, "!=", true); |
| 275 | } | 275 | } |
| 276 | 276 | ||
| 277 | void EmitFPUnordNotEqual16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view lhs, | 277 | void EmitFPUnordNotEqual16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view lhs, |
| @@ -281,12 +281,12 @@ void EmitFPUnordNotEqual16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] s | |||
| 281 | 281 | ||
| 282 | void EmitFPUnordNotEqual32(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, | 282 | void EmitFPUnordNotEqual32(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, |
| 283 | std::string_view rhs) { | 283 | std::string_view rhs) { |
| 284 | Compare(ctx, inst, lhs, rhs, "!=", "F", false, true); | 284 | Compare(ctx, inst, lhs, rhs, "!=", false); |
| 285 | } | 285 | } |
| 286 | 286 | ||
| 287 | void EmitFPUnordNotEqual64(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, | 287 | void EmitFPUnordNotEqual64(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, |
| 288 | std::string_view rhs) { | 288 | std::string_view rhs) { |
| 289 | Compare(ctx, inst, lhs, rhs, "!=", "F64", false, true); | 289 | Compare(ctx, inst, lhs, rhs, "!=", false); |
| 290 | } | 290 | } |
| 291 | 291 | ||
| 292 | void EmitFPOrdLessThan16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view lhs, | 292 | void EmitFPOrdLessThan16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view lhs, |
| @@ -296,12 +296,12 @@ void EmitFPOrdLessThan16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std | |||
| 296 | 296 | ||
| 297 | void EmitFPOrdLessThan32(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, | 297 | void EmitFPOrdLessThan32(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, |
| 298 | std::string_view rhs) { | 298 | std::string_view rhs) { |
| 299 | Compare(ctx, inst, lhs, rhs, "<", "F", true); | 299 | Compare(ctx, inst, lhs, rhs, "<", true); |
| 300 | } | 300 | } |
| 301 | 301 | ||
| 302 | void EmitFPOrdLessThan64(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, | 302 | void EmitFPOrdLessThan64(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, |
| 303 | std::string_view rhs) { | 303 | std::string_view rhs) { |
| 304 | Compare(ctx, inst, lhs, rhs, "<", "F64", true); | 304 | Compare(ctx, inst, lhs, rhs, "<", true); |
| 305 | } | 305 | } |
| 306 | 306 | ||
| 307 | void EmitFPUnordLessThan16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view lhs, | 307 | void EmitFPUnordLessThan16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view lhs, |
| @@ -311,12 +311,12 @@ void EmitFPUnordLessThan16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] s | |||
| 311 | 311 | ||
| 312 | void EmitFPUnordLessThan32(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, | 312 | void EmitFPUnordLessThan32(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, |
| 313 | std::string_view rhs) { | 313 | std::string_view rhs) { |
| 314 | Compare(ctx, inst, lhs, rhs, "<", "F", false); | 314 | Compare(ctx, inst, lhs, rhs, "<", false); |
| 315 | } | 315 | } |
| 316 | 316 | ||
| 317 | void EmitFPUnordLessThan64(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, | 317 | void EmitFPUnordLessThan64(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, |
| 318 | std::string_view rhs) { | 318 | std::string_view rhs) { |
| 319 | Compare(ctx, inst, lhs, rhs, "<", "F64", false); | 319 | Compare(ctx, inst, lhs, rhs, "<", false); |
| 320 | } | 320 | } |
| 321 | 321 | ||
| 322 | void EmitFPOrdGreaterThan16([[maybe_unused]] EmitContext& ctx, | 322 | void EmitFPOrdGreaterThan16([[maybe_unused]] EmitContext& ctx, |
| @@ -327,12 +327,12 @@ void EmitFPOrdGreaterThan16([[maybe_unused]] EmitContext& ctx, | |||
| 327 | 327 | ||
| 328 | void EmitFPOrdGreaterThan32(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, | 328 | void EmitFPOrdGreaterThan32(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, |
| 329 | std::string_view rhs) { | 329 | std::string_view rhs) { |
| 330 | Compare(ctx, inst, lhs, rhs, ">", "F", true); | 330 | Compare(ctx, inst, lhs, rhs, ">", true); |
| 331 | } | 331 | } |
| 332 | 332 | ||
| 333 | void EmitFPOrdGreaterThan64(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, | 333 | void EmitFPOrdGreaterThan64(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, |
| 334 | std::string_view rhs) { | 334 | std::string_view rhs) { |
| 335 | Compare(ctx, inst, lhs, rhs, ">", "F64", true); | 335 | Compare(ctx, inst, lhs, rhs, ">", true); |
| 336 | } | 336 | } |
| 337 | 337 | ||
| 338 | void EmitFPUnordGreaterThan16([[maybe_unused]] EmitContext& ctx, | 338 | void EmitFPUnordGreaterThan16([[maybe_unused]] EmitContext& ctx, |
| @@ -343,12 +343,12 @@ void EmitFPUnordGreaterThan16([[maybe_unused]] EmitContext& ctx, | |||
| 343 | 343 | ||
| 344 | void EmitFPUnordGreaterThan32(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, | 344 | void EmitFPUnordGreaterThan32(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, |
| 345 | std::string_view rhs) { | 345 | std::string_view rhs) { |
| 346 | Compare(ctx, inst, lhs, rhs, ">", "F", false); | 346 | Compare(ctx, inst, lhs, rhs, ">", false); |
| 347 | } | 347 | } |
| 348 | 348 | ||
| 349 | void EmitFPUnordGreaterThan64(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, | 349 | void EmitFPUnordGreaterThan64(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, |
| 350 | std::string_view rhs) { | 350 | std::string_view rhs) { |
| 351 | Compare(ctx, inst, lhs, rhs, ">", "F64", false); | 351 | Compare(ctx, inst, lhs, rhs, ">", false); |
| 352 | } | 352 | } |
| 353 | 353 | ||
| 354 | void EmitFPOrdLessThanEqual16([[maybe_unused]] EmitContext& ctx, | 354 | void EmitFPOrdLessThanEqual16([[maybe_unused]] EmitContext& ctx, |
| @@ -359,12 +359,12 @@ void EmitFPOrdLessThanEqual16([[maybe_unused]] EmitContext& ctx, | |||
| 359 | 359 | ||
| 360 | void EmitFPOrdLessThanEqual32(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, | 360 | void EmitFPOrdLessThanEqual32(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, |
| 361 | std::string_view rhs) { | 361 | std::string_view rhs) { |
| 362 | Compare(ctx, inst, lhs, rhs, "<=", "F", true); | 362 | Compare(ctx, inst, lhs, rhs, "<=", true); |
| 363 | } | 363 | } |
| 364 | 364 | ||
| 365 | void EmitFPOrdLessThanEqual64(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, | 365 | void EmitFPOrdLessThanEqual64(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, |
| 366 | std::string_view rhs) { | 366 | std::string_view rhs) { |
| 367 | Compare(ctx, inst, lhs, rhs, "<=", "F64", true); | 367 | Compare(ctx, inst, lhs, rhs, "<=", true); |
| 368 | } | 368 | } |
| 369 | 369 | ||
| 370 | void EmitFPUnordLessThanEqual16([[maybe_unused]] EmitContext& ctx, | 370 | void EmitFPUnordLessThanEqual16([[maybe_unused]] EmitContext& ctx, |
| @@ -375,12 +375,12 @@ void EmitFPUnordLessThanEqual16([[maybe_unused]] EmitContext& ctx, | |||
| 375 | 375 | ||
| 376 | void EmitFPUnordLessThanEqual32(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, | 376 | void EmitFPUnordLessThanEqual32(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, |
| 377 | std::string_view rhs) { | 377 | std::string_view rhs) { |
| 378 | Compare(ctx, inst, lhs, rhs, "<=", "F", false); | 378 | Compare(ctx, inst, lhs, rhs, "<=", false); |
| 379 | } | 379 | } |
| 380 | 380 | ||
| 381 | void EmitFPUnordLessThanEqual64(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, | 381 | void EmitFPUnordLessThanEqual64(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, |
| 382 | std::string_view rhs) { | 382 | std::string_view rhs) { |
| 383 | Compare(ctx, inst, lhs, rhs, "<=", "F64", false); | 383 | Compare(ctx, inst, lhs, rhs, "<=", false); |
| 384 | } | 384 | } |
| 385 | 385 | ||
| 386 | void EmitFPOrdGreaterThanEqual16([[maybe_unused]] EmitContext& ctx, | 386 | void EmitFPOrdGreaterThanEqual16([[maybe_unused]] EmitContext& ctx, |
| @@ -391,12 +391,12 @@ void EmitFPOrdGreaterThanEqual16([[maybe_unused]] EmitContext& ctx, | |||
| 391 | 391 | ||
| 392 | void EmitFPOrdGreaterThanEqual32(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, | 392 | void EmitFPOrdGreaterThanEqual32(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, |
| 393 | std::string_view rhs) { | 393 | std::string_view rhs) { |
| 394 | Compare(ctx, inst, lhs, rhs, ">=", "F", true); | 394 | Compare(ctx, inst, lhs, rhs, ">=", true); |
| 395 | } | 395 | } |
| 396 | 396 | ||
| 397 | void EmitFPOrdGreaterThanEqual64(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, | 397 | void EmitFPOrdGreaterThanEqual64(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, |
| 398 | std::string_view rhs) { | 398 | std::string_view rhs) { |
| 399 | Compare(ctx, inst, lhs, rhs, ">=", "F64", true); | 399 | Compare(ctx, inst, lhs, rhs, ">=", true); |
| 400 | } | 400 | } |
| 401 | 401 | ||
| 402 | void EmitFPUnordGreaterThanEqual16([[maybe_unused]] EmitContext& ctx, | 402 | void EmitFPUnordGreaterThanEqual16([[maybe_unused]] EmitContext& ctx, |
| @@ -407,12 +407,12 @@ void EmitFPUnordGreaterThanEqual16([[maybe_unused]] EmitContext& ctx, | |||
| 407 | 407 | ||
| 408 | void EmitFPUnordGreaterThanEqual32(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, | 408 | void EmitFPUnordGreaterThanEqual32(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, |
| 409 | std::string_view rhs) { | 409 | std::string_view rhs) { |
| 410 | Compare(ctx, inst, lhs, rhs, ">=", "F", false); | 410 | Compare(ctx, inst, lhs, rhs, ">=", false); |
| 411 | } | 411 | } |
| 412 | 412 | ||
| 413 | void EmitFPUnordGreaterThanEqual64(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, | 413 | void EmitFPUnordGreaterThanEqual64(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, |
| 414 | std::string_view rhs) { | 414 | std::string_view rhs) { |
| 415 | Compare(ctx, inst, lhs, rhs, ">=", "F64", false); | 415 | Compare(ctx, inst, lhs, rhs, ">=", false); |
| 416 | } | 416 | } |
| 417 | 417 | ||
| 418 | void EmitFPIsNan16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | 418 | void EmitFPIsNan16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, |