diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/common/logging/backend.cpp | 64 | ||||
| -rw-r--r-- | src/common/logging/backend.h | 2 | ||||
| -rw-r--r-- | src/common/logging/log_entry.h | 1 | ||||
| -rw-r--r-- | src/shader_recompiler/backend/spirv/emit_context.cpp | 143 | ||||
| -rw-r--r-- | src/shader_recompiler/backend/spirv/emit_context.h | 11 | ||||
| -rw-r--r-- | src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp | 70 | ||||
| -rw-r--r-- | src/yuzu/main.cpp | 2 |
7 files changed, 194 insertions, 99 deletions
diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp index 0e85a9c1d..c51c05b28 100644 --- a/src/common/logging/backend.cpp +++ b/src/common/logging/backend.cpp | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | #include <chrono> | 6 | #include <chrono> |
| 7 | #include <climits> | 7 | #include <climits> |
| 8 | #include <exception> | 8 | #include <exception> |
| 9 | #include <stop_token> | ||
| 9 | #include <thread> | 10 | #include <thread> |
| 10 | #include <vector> | 11 | #include <vector> |
| 11 | 12 | ||
| @@ -186,6 +187,10 @@ public: | |||
| 186 | initialization_in_progress_suppress_logging = false; | 187 | initialization_in_progress_suppress_logging = false; |
| 187 | } | 188 | } |
| 188 | 189 | ||
| 190 | static void Start() { | ||
| 191 | instance->StartBackendThread(); | ||
| 192 | } | ||
| 193 | |||
| 189 | Impl(const Impl&) = delete; | 194 | Impl(const Impl&) = delete; |
| 190 | Impl& operator=(const Impl&) = delete; | 195 | Impl& operator=(const Impl&) = delete; |
| 191 | 196 | ||
| @@ -201,7 +206,7 @@ public: | |||
| 201 | } | 206 | } |
| 202 | 207 | ||
| 203 | void PushEntry(Class log_class, Level log_level, const char* filename, unsigned int line_num, | 208 | void PushEntry(Class log_class, Level log_level, const char* filename, unsigned int line_num, |
| 204 | const char* function, std::string message) { | 209 | const char* function, std::string&& message) { |
| 205 | if (!filter.CheckMessage(log_class, log_level)) | 210 | if (!filter.CheckMessage(log_class, log_level)) |
| 206 | return; | 211 | return; |
| 207 | const Entry& entry = | 212 | const Entry& entry = |
| @@ -211,40 +216,41 @@ public: | |||
| 211 | 216 | ||
| 212 | private: | 217 | private: |
| 213 | Impl(const std::filesystem::path& file_backend_filename, const Filter& filter_) | 218 | Impl(const std::filesystem::path& file_backend_filename, const Filter& filter_) |
| 214 | : filter{filter_}, file_backend{file_backend_filename}, backend_thread{std::thread([this] { | 219 | : filter{filter_}, file_backend{file_backend_filename} {} |
| 215 | Common::SetCurrentThreadName("yuzu:Log"); | ||
| 216 | Entry entry; | ||
| 217 | const auto write_logs = [this, &entry]() { | ||
| 218 | ForEachBackend([&entry](Backend& backend) { backend.Write(entry); }); | ||
| 219 | }; | ||
| 220 | while (true) { | ||
| 221 | entry = message_queue.PopWait(); | ||
| 222 | if (entry.final_entry) { | ||
| 223 | break; | ||
| 224 | } | ||
| 225 | write_logs(); | ||
| 226 | } | ||
| 227 | // Drain the logging queue. Only writes out up to MAX_LOGS_TO_WRITE to prevent a | ||
| 228 | // case where a system is repeatedly spamming logs even on close. | ||
| 229 | int max_logs_to_write = filter.IsDebug() ? INT_MAX : 100; | ||
| 230 | while (max_logs_to_write-- && message_queue.Pop(entry)) { | ||
| 231 | write_logs(); | ||
| 232 | } | ||
| 233 | })} {} | ||
| 234 | 220 | ||
| 235 | ~Impl() { | 221 | ~Impl() { |
| 236 | StopBackendThread(); | 222 | StopBackendThread(); |
| 237 | } | 223 | } |
| 238 | 224 | ||
| 225 | void StartBackendThread() { | ||
| 226 | backend_thread = std::thread([this] { | ||
| 227 | Common::SetCurrentThreadName("yuzu:Log"); | ||
| 228 | Entry entry; | ||
| 229 | const auto write_logs = [this, &entry]() { | ||
| 230 | ForEachBackend([&entry](Backend& backend) { backend.Write(entry); }); | ||
| 231 | }; | ||
| 232 | while (!stop.stop_requested()) { | ||
| 233 | entry = message_queue.PopWait(stop.get_token()); | ||
| 234 | if (entry.filename != nullptr) { | ||
| 235 | write_logs(); | ||
| 236 | } | ||
| 237 | } | ||
| 238 | // Drain the logging queue. Only writes out up to MAX_LOGS_TO_WRITE to prevent a | ||
| 239 | // case where a system is repeatedly spamming logs even on close. | ||
| 240 | int max_logs_to_write = filter.IsDebug() ? INT_MAX : 100; | ||
| 241 | while (max_logs_to_write-- && message_queue.Pop(entry)) { | ||
| 242 | write_logs(); | ||
| 243 | } | ||
| 244 | }); | ||
| 245 | } | ||
| 246 | |||
| 239 | void StopBackendThread() { | 247 | void StopBackendThread() { |
| 240 | Entry stop_entry{}; | 248 | stop.request_stop(); |
| 241 | stop_entry.final_entry = true; | ||
| 242 | message_queue.Push(stop_entry); | ||
| 243 | backend_thread.join(); | 249 | backend_thread.join(); |
| 244 | } | 250 | } |
| 245 | 251 | ||
| 246 | Entry CreateEntry(Class log_class, Level log_level, const char* filename, unsigned int line_nr, | 252 | Entry CreateEntry(Class log_class, Level log_level, const char* filename, unsigned int line_nr, |
| 247 | const char* function, std::string message) const { | 253 | const char* function, std::string&& message) const { |
| 248 | using std::chrono::duration_cast; | 254 | using std::chrono::duration_cast; |
| 249 | using std::chrono::microseconds; | 255 | using std::chrono::microseconds; |
| 250 | using std::chrono::steady_clock; | 256 | using std::chrono::steady_clock; |
| @@ -257,7 +263,6 @@ private: | |||
| 257 | .line_num = line_nr, | 263 | .line_num = line_nr, |
| 258 | .function = function, | 264 | .function = function, |
| 259 | .message = std::move(message), | 265 | .message = std::move(message), |
| 260 | .final_entry = false, | ||
| 261 | }; | 266 | }; |
| 262 | } | 267 | } |
| 263 | 268 | ||
| @@ -278,8 +283,9 @@ private: | |||
| 278 | ColorConsoleBackend color_console_backend{}; | 283 | ColorConsoleBackend color_console_backend{}; |
| 279 | FileBackend file_backend; | 284 | FileBackend file_backend; |
| 280 | 285 | ||
| 286 | std::stop_source stop; | ||
| 281 | std::thread backend_thread; | 287 | std::thread backend_thread; |
| 282 | MPSCQueue<Entry> message_queue{}; | 288 | MPSCQueue<Entry, true> message_queue{}; |
| 283 | std::chrono::steady_clock::time_point time_origin{std::chrono::steady_clock::now()}; | 289 | std::chrono::steady_clock::time_point time_origin{std::chrono::steady_clock::now()}; |
| 284 | }; | 290 | }; |
| 285 | } // namespace | 291 | } // namespace |
| @@ -288,6 +294,10 @@ void Initialize() { | |||
| 288 | Impl::Initialize(); | 294 | Impl::Initialize(); |
| 289 | } | 295 | } |
| 290 | 296 | ||
| 297 | void Start() { | ||
| 298 | Impl::Start(); | ||
| 299 | } | ||
| 300 | |||
| 291 | void DisableLoggingInTests() { | 301 | void DisableLoggingInTests() { |
| 292 | initialization_in_progress_suppress_logging = true; | 302 | initialization_in_progress_suppress_logging = true; |
| 293 | } | 303 | } |
diff --git a/src/common/logging/backend.h b/src/common/logging/backend.h index cb7839ee9..bf785f402 100644 --- a/src/common/logging/backend.h +++ b/src/common/logging/backend.h | |||
| @@ -14,6 +14,8 @@ class Filter; | |||
| 14 | /// Initializes the logging system. This should be the first thing called in main. | 14 | /// Initializes the logging system. This should be the first thing called in main. |
| 15 | void Initialize(); | 15 | void Initialize(); |
| 16 | 16 | ||
| 17 | void Start(); | ||
| 18 | |||
| 17 | void DisableLoggingInTests(); | 19 | void DisableLoggingInTests(); |
| 18 | 20 | ||
| 19 | /** | 21 | /** |
diff --git a/src/common/logging/log_entry.h b/src/common/logging/log_entry.h index dd6f44841..b28570071 100644 --- a/src/common/logging/log_entry.h +++ b/src/common/logging/log_entry.h | |||
| @@ -22,7 +22,6 @@ struct Entry { | |||
| 22 | unsigned int line_num = 0; | 22 | unsigned int line_num = 0; |
| 23 | std::string function; | 23 | std::string function; |
| 24 | std::string message; | 24 | std::string message; |
| 25 | bool final_entry = false; | ||
| 26 | }; | 25 | }; |
| 27 | 26 | ||
| 28 | } // namespace Common::Log | 27 | } // namespace Common::Log |
diff --git a/src/shader_recompiler/backend/spirv/emit_context.cpp b/src/shader_recompiler/backend/spirv/emit_context.cpp index 2885e6799..3c84e6466 100644 --- a/src/shader_recompiler/backend/spirv/emit_context.cpp +++ b/src/shader_recompiler/backend/spirv/emit_context.cpp | |||
| @@ -430,15 +430,33 @@ Id DescType(EmitContext& ctx, Id sampled_type, Id pointer_type, u32 count) { | |||
| 430 | } | 430 | } |
| 431 | } | 431 | } |
| 432 | 432 | ||
| 433 | size_t FindNextUnusedLocation(const std::bitset<IR::NUM_GENERICS>& used_locations, | 433 | size_t FindAndSetNextUnusedLocation(std::bitset<IR::NUM_GENERICS>& used_locations, |
| 434 | size_t start_offset) { | 434 | size_t& start_offset) { |
| 435 | for (size_t location = start_offset; location < used_locations.size(); ++location) { | 435 | for (size_t location = start_offset; location < used_locations.size(); ++location) { |
| 436 | if (!used_locations.test(location)) { | 436 | if (!used_locations.test(location)) { |
| 437 | start_offset = location; | ||
| 438 | used_locations.set(location); | ||
| 437 | return location; | 439 | return location; |
| 438 | } | 440 | } |
| 439 | } | 441 | } |
| 440 | throw RuntimeError("Unable to get an unused location for legacy attribute"); | 442 | throw RuntimeError("Unable to get an unused location for legacy attribute"); |
| 441 | } | 443 | } |
| 444 | |||
| 445 | Id DefineLegacyInput(EmitContext& ctx, std::bitset<IR::NUM_GENERICS>& used_locations, | ||
| 446 | size_t& start_offset) { | ||
| 447 | const Id id{DefineInput(ctx, ctx.F32[4], true)}; | ||
| 448 | const size_t location = FindAndSetNextUnusedLocation(used_locations, start_offset); | ||
| 449 | ctx.Decorate(id, spv::Decoration::Location, location); | ||
| 450 | return id; | ||
| 451 | } | ||
| 452 | |||
| 453 | Id DefineLegacyOutput(EmitContext& ctx, std::bitset<IR::NUM_GENERICS>& used_locations, | ||
| 454 | size_t& start_offset, std::optional<u32> invocations) { | ||
| 455 | const Id id{DefineOutput(ctx, ctx.F32[4], invocations)}; | ||
| 456 | const size_t location = FindAndSetNextUnusedLocation(used_locations, start_offset); | ||
| 457 | ctx.Decorate(id, spv::Decoration::Location, location); | ||
| 458 | return id; | ||
| 459 | } | ||
| 442 | } // Anonymous namespace | 460 | } // Anonymous namespace |
| 443 | 461 | ||
| 444 | void VectorTypes::Define(Sirit::Module& sirit_ctx, Id base_type, std::string_view name) { | 462 | void VectorTypes::Define(Sirit::Module& sirit_ctx, Id base_type, std::string_view name) { |
| @@ -520,6 +538,64 @@ Id EmitContext::BitOffset16(const IR::Value& offset) { | |||
| 520 | return OpBitwiseAnd(U32[1], OpShiftLeftLogical(U32[1], Def(offset), Const(3u)), Const(16u)); | 538 | return OpBitwiseAnd(U32[1], OpShiftLeftLogical(U32[1], Def(offset), Const(3u)), Const(16u)); |
| 521 | } | 539 | } |
| 522 | 540 | ||
| 541 | Id EmitContext::InputLegacyAttribute(IR::Attribute attribute) { | ||
| 542 | if (attribute >= IR::Attribute::ColorFrontDiffuseR && | ||
| 543 | attribute <= IR::Attribute::ColorFrontDiffuseA) { | ||
| 544 | return input_front_color; | ||
| 545 | } | ||
| 546 | if (attribute >= IR::Attribute::ColorFrontSpecularR && | ||
| 547 | attribute <= IR::Attribute::ColorFrontSpecularA) { | ||
| 548 | return input_front_secondary_color; | ||
| 549 | } | ||
| 550 | if (attribute >= IR::Attribute::ColorBackDiffuseR && | ||
| 551 | attribute <= IR::Attribute::ColorBackDiffuseA) { | ||
| 552 | return input_back_color; | ||
| 553 | } | ||
| 554 | if (attribute >= IR::Attribute::ColorBackSpecularR && | ||
| 555 | attribute <= IR::Attribute::ColorBackSpecularA) { | ||
| 556 | return input_back_secondary_color; | ||
| 557 | } | ||
| 558 | if (attribute == IR::Attribute::FogCoordinate) { | ||
| 559 | return input_fog_frag_coord; | ||
| 560 | } | ||
| 561 | if (attribute >= IR::Attribute::FixedFncTexture0S && | ||
| 562 | attribute <= IR::Attribute::FixedFncTexture9Q) { | ||
| 563 | u32 index = | ||
| 564 | (static_cast<u32>(attribute) - static_cast<u32>(IR::Attribute::FixedFncTexture0S)) / 4; | ||
| 565 | return input_fixed_fnc_textures[index]; | ||
| 566 | } | ||
| 567 | throw InvalidArgument("Attribute is not legacy attribute {}", attribute); | ||
| 568 | } | ||
| 569 | |||
| 570 | Id EmitContext::OutputLegacyAttribute(IR::Attribute attribute) { | ||
| 571 | if (attribute >= IR::Attribute::ColorFrontDiffuseR && | ||
| 572 | attribute <= IR::Attribute::ColorFrontDiffuseA) { | ||
| 573 | return output_front_color; | ||
| 574 | } | ||
| 575 | if (attribute >= IR::Attribute::ColorFrontSpecularR && | ||
| 576 | attribute <= IR::Attribute::ColorFrontSpecularA) { | ||
| 577 | return output_front_secondary_color; | ||
| 578 | } | ||
| 579 | if (attribute >= IR::Attribute::ColorBackDiffuseR && | ||
| 580 | attribute <= IR::Attribute::ColorBackDiffuseA) { | ||
| 581 | return output_back_color; | ||
| 582 | } | ||
| 583 | if (attribute >= IR::Attribute::ColorBackSpecularR && | ||
| 584 | attribute <= IR::Attribute::ColorBackSpecularA) { | ||
| 585 | return output_back_secondary_color; | ||
| 586 | } | ||
| 587 | if (attribute == IR::Attribute::FogCoordinate) { | ||
| 588 | return output_fog_frag_coord; | ||
| 589 | } | ||
| 590 | if (attribute >= IR::Attribute::FixedFncTexture0S && | ||
| 591 | attribute <= IR::Attribute::FixedFncTexture9Q) { | ||
| 592 | u32 index = | ||
| 593 | (static_cast<u32>(attribute) - static_cast<u32>(IR::Attribute::FixedFncTexture0S)) / 4; | ||
| 594 | return output_fixed_fnc_textures[index]; | ||
| 595 | } | ||
| 596 | throw InvalidArgument("Attribute is not legacy attribute {}", attribute); | ||
| 597 | } | ||
| 598 | |||
| 523 | void EmitContext::DefineCommonTypes(const Info& info) { | 599 | void EmitContext::DefineCommonTypes(const Info& info) { |
| 524 | void_id = TypeVoid(); | 600 | void_id = TypeVoid(); |
| 525 | 601 | ||
| @@ -1279,22 +1355,26 @@ void EmitContext::DefineInputs(const IR::Program& program) { | |||
| 1279 | } | 1355 | } |
| 1280 | size_t previous_unused_location = 0; | 1356 | size_t previous_unused_location = 0; |
| 1281 | if (loads.AnyComponent(IR::Attribute::ColorFrontDiffuseR)) { | 1357 | if (loads.AnyComponent(IR::Attribute::ColorFrontDiffuseR)) { |
| 1282 | const size_t location = FindNextUnusedLocation(used_locations, previous_unused_location); | 1358 | input_front_color = DefineLegacyInput(*this, used_locations, previous_unused_location); |
| 1283 | previous_unused_location = location; | 1359 | } |
| 1284 | used_locations.set(location); | 1360 | if (loads.AnyComponent(IR::Attribute::ColorFrontSpecularR)) { |
| 1285 | const Id id{DefineInput(*this, F32[4], true)}; | 1361 | input_front_secondary_color = |
| 1286 | Decorate(id, spv::Decoration::Location, location); | 1362 | DefineLegacyInput(*this, used_locations, previous_unused_location); |
| 1287 | input_front_color = id; | 1363 | } |
| 1364 | if (loads.AnyComponent(IR::Attribute::ColorBackDiffuseR)) { | ||
| 1365 | input_back_color = DefineLegacyInput(*this, used_locations, previous_unused_location); | ||
| 1366 | } | ||
| 1367 | if (loads.AnyComponent(IR::Attribute::ColorBackSpecularR)) { | ||
| 1368 | input_back_secondary_color = | ||
| 1369 | DefineLegacyInput(*this, used_locations, previous_unused_location); | ||
| 1370 | } | ||
| 1371 | if (loads.AnyComponent(IR::Attribute::FogCoordinate)) { | ||
| 1372 | input_fog_frag_coord = DefineLegacyInput(*this, used_locations, previous_unused_location); | ||
| 1288 | } | 1373 | } |
| 1289 | for (size_t index = 0; index < NUM_FIXEDFNCTEXTURE; ++index) { | 1374 | for (size_t index = 0; index < NUM_FIXEDFNCTEXTURE; ++index) { |
| 1290 | if (loads.AnyComponent(IR::Attribute::FixedFncTexture0S + index * 4)) { | 1375 | if (loads.AnyComponent(IR::Attribute::FixedFncTexture0S + index * 4)) { |
| 1291 | const size_t location = | 1376 | input_fixed_fnc_textures[index] = |
| 1292 | FindNextUnusedLocation(used_locations, previous_unused_location); | 1377 | DefineLegacyInput(*this, used_locations, previous_unused_location); |
| 1293 | previous_unused_location = location; | ||
| 1294 | used_locations.set(location); | ||
| 1295 | const Id id{DefineInput(*this, F32[4], true)}; | ||
| 1296 | Decorate(id, spv::Decoration::Location, location); | ||
| 1297 | input_fixed_fnc_textures[index] = id; | ||
| 1298 | } | 1378 | } |
| 1299 | } | 1379 | } |
| 1300 | if (stage == Stage::TessellationEval) { | 1380 | if (stage == Stage::TessellationEval) { |
| @@ -1356,22 +1436,29 @@ void EmitContext::DefineOutputs(const IR::Program& program) { | |||
| 1356 | } | 1436 | } |
| 1357 | size_t previous_unused_location = 0; | 1437 | size_t previous_unused_location = 0; |
| 1358 | if (info.stores.AnyComponent(IR::Attribute::ColorFrontDiffuseR)) { | 1438 | if (info.stores.AnyComponent(IR::Attribute::ColorFrontDiffuseR)) { |
| 1359 | const size_t location = FindNextUnusedLocation(used_locations, previous_unused_location); | 1439 | output_front_color = |
| 1360 | previous_unused_location = location; | 1440 | DefineLegacyOutput(*this, used_locations, previous_unused_location, invocations); |
| 1361 | used_locations.set(location); | 1441 | } |
| 1362 | const Id id{DefineOutput(*this, F32[4], invocations)}; | 1442 | if (info.stores.AnyComponent(IR::Attribute::ColorFrontSpecularR)) { |
| 1363 | Decorate(id, spv::Decoration::Location, static_cast<u32>(location)); | 1443 | output_front_secondary_color = |
| 1364 | output_front_color = id; | 1444 | DefineLegacyOutput(*this, used_locations, previous_unused_location, invocations); |
| 1445 | } | ||
| 1446 | if (info.stores.AnyComponent(IR::Attribute::ColorBackDiffuseR)) { | ||
| 1447 | output_back_color = | ||
| 1448 | DefineLegacyOutput(*this, used_locations, previous_unused_location, invocations); | ||
| 1449 | } | ||
| 1450 | if (info.stores.AnyComponent(IR::Attribute::ColorBackSpecularR)) { | ||
| 1451 | output_back_secondary_color = | ||
| 1452 | DefineLegacyOutput(*this, used_locations, previous_unused_location, invocations); | ||
| 1453 | } | ||
| 1454 | if (info.stores.AnyComponent(IR::Attribute::FogCoordinate)) { | ||
| 1455 | output_fog_frag_coord = | ||
| 1456 | DefineLegacyOutput(*this, used_locations, previous_unused_location, invocations); | ||
| 1365 | } | 1457 | } |
| 1366 | for (size_t index = 0; index < NUM_FIXEDFNCTEXTURE; ++index) { | 1458 | for (size_t index = 0; index < NUM_FIXEDFNCTEXTURE; ++index) { |
| 1367 | if (info.stores.AnyComponent(IR::Attribute::FixedFncTexture0S + index * 4)) { | 1459 | if (info.stores.AnyComponent(IR::Attribute::FixedFncTexture0S + index * 4)) { |
| 1368 | const size_t location = | 1460 | output_fixed_fnc_textures[index] = |
| 1369 | FindNextUnusedLocation(used_locations, previous_unused_location); | 1461 | DefineLegacyOutput(*this, used_locations, previous_unused_location, invocations); |
| 1370 | previous_unused_location = location; | ||
| 1371 | used_locations.set(location); | ||
| 1372 | const Id id{DefineOutput(*this, F32[4], invocations)}; | ||
| 1373 | Decorate(id, spv::Decoration::Location, location); | ||
| 1374 | output_fixed_fnc_textures[index] = id; | ||
| 1375 | } | 1462 | } |
| 1376 | } | 1463 | } |
| 1377 | switch (stage) { | 1464 | switch (stage) { |
diff --git a/src/shader_recompiler/backend/spirv/emit_context.h b/src/shader_recompiler/backend/spirv/emit_context.h index 847d0c0e6..112c52382 100644 --- a/src/shader_recompiler/backend/spirv/emit_context.h +++ b/src/shader_recompiler/backend/spirv/emit_context.h | |||
| @@ -113,6 +113,9 @@ public: | |||
| 113 | [[nodiscard]] Id BitOffset8(const IR::Value& offset); | 113 | [[nodiscard]] Id BitOffset8(const IR::Value& offset); |
| 114 | [[nodiscard]] Id BitOffset16(const IR::Value& offset); | 114 | [[nodiscard]] Id BitOffset16(const IR::Value& offset); |
| 115 | 115 | ||
| 116 | Id InputLegacyAttribute(IR::Attribute attribute); | ||
| 117 | Id OutputLegacyAttribute(IR::Attribute attribute); | ||
| 118 | |||
| 116 | Id Const(u32 value) { | 119 | Id Const(u32 value) { |
| 117 | return Constant(U32[1], value); | 120 | return Constant(U32[1], value); |
| 118 | } | 121 | } |
| @@ -269,12 +272,20 @@ public: | |||
| 269 | 272 | ||
| 270 | Id input_position{}; | 273 | Id input_position{}; |
| 271 | Id input_front_color{}; | 274 | Id input_front_color{}; |
| 275 | Id input_front_secondary_color{}; | ||
| 276 | Id input_back_color{}; | ||
| 277 | Id input_back_secondary_color{}; | ||
| 278 | Id input_fog_frag_coord{}; | ||
| 272 | std::array<Id, 10> input_fixed_fnc_textures{}; | 279 | std::array<Id, 10> input_fixed_fnc_textures{}; |
| 273 | std::array<Id, 32> input_generics{}; | 280 | std::array<Id, 32> input_generics{}; |
| 274 | 281 | ||
| 275 | Id output_point_size{}; | 282 | Id output_point_size{}; |
| 276 | Id output_position{}; | 283 | Id output_position{}; |
| 277 | Id output_front_color{}; | 284 | Id output_front_color{}; |
| 285 | Id output_front_secondary_color{}; | ||
| 286 | Id output_back_color{}; | ||
| 287 | Id output_back_secondary_color{}; | ||
| 288 | Id output_fog_frag_coord{}; | ||
| 278 | std::array<Id, 10> output_fixed_fnc_textures{}; | 289 | std::array<Id, 10> output_fixed_fnc_textures{}; |
| 279 | std::array<std::array<GenericElementInfo, 4>, 32> output_generics{}; | 290 | std::array<std::array<GenericElementInfo, 4>, 32> output_generics{}; |
| 280 | 291 | ||
diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp b/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp index 6f60c6574..d3a93d5f4 100644 --- a/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp +++ b/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp | |||
| @@ -43,23 +43,12 @@ Id AttrPointer(EmitContext& ctx, Id pointer_type, Id vertex, Id base, Args&&... | |||
| 43 | } | 43 | } |
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | bool IsFixedFncTexture(IR::Attribute attribute) { | 46 | bool IsLegacyAttribute(IR::Attribute attribute) { |
| 47 | return attribute >= IR::Attribute::FixedFncTexture0S && | 47 | return (attribute >= IR::Attribute::ColorFrontDiffuseR && |
| 48 | attribute <= IR::Attribute::FixedFncTexture9Q; | 48 | attribute <= IR::Attribute::ColorBackSpecularA) || |
| 49 | } | 49 | attribute == IR::Attribute::FogCoordinate || |
| 50 | 50 | (attribute >= IR::Attribute::FixedFncTexture0S && | |
| 51 | u32 FixedFncTextureAttributeIndex(IR::Attribute attribute) { | 51 | attribute <= IR::Attribute::FixedFncTexture9Q); |
| 52 | if (!IsFixedFncTexture(attribute)) { | ||
| 53 | throw InvalidArgument("Attribute {} is not a FixedFncTexture", attribute); | ||
| 54 | } | ||
| 55 | return (static_cast<u32>(attribute) - static_cast<u32>(IR::Attribute::FixedFncTexture0S)) / 4u; | ||
| 56 | } | ||
| 57 | |||
| 58 | u32 FixedFncTextureAttributeElement(IR::Attribute attribute) { | ||
| 59 | if (!IsFixedFncTexture(attribute)) { | ||
| 60 | throw InvalidArgument("Attribute {} is not a FixedFncTexture", attribute); | ||
| 61 | } | ||
| 62 | return static_cast<u32>(attribute) % 4u; | ||
| 63 | } | 52 | } |
| 64 | 53 | ||
| 65 | template <typename... Args> | 54 | template <typename... Args> |
| @@ -93,12 +82,16 @@ std::optional<OutAttr> OutputAttrPointer(EmitContext& ctx, IR::Attribute attr) { | |||
| 93 | return OutputAccessChain(ctx, ctx.output_f32, info.id, index_id); | 82 | return OutputAccessChain(ctx, ctx.output_f32, info.id, index_id); |
| 94 | } | 83 | } |
| 95 | } | 84 | } |
| 96 | if (IsFixedFncTexture(attr)) { | 85 | if (IsLegacyAttribute(attr)) { |
| 97 | const u32 index{FixedFncTextureAttributeIndex(attr)}; | 86 | if (attr == IR::Attribute::FogCoordinate) { |
| 98 | const u32 element{FixedFncTextureAttributeElement(attr)}; | 87 | return OutputAccessChain(ctx, ctx.output_f32, ctx.OutputLegacyAttribute(attr), |
| 99 | const Id element_id{ctx.Const(element)}; | 88 | ctx.Const(0u)); |
| 100 | return OutputAccessChain(ctx, ctx.output_f32, ctx.output_fixed_fnc_textures[index], | 89 | } else { |
| 101 | element_id); | 90 | const u32 element{static_cast<u32>(attr) % 4}; |
| 91 | const Id element_id{ctx.Const(element)}; | ||
| 92 | return OutputAccessChain(ctx, ctx.output_f32, ctx.OutputLegacyAttribute(attr), | ||
| 93 | element_id); | ||
| 94 | } | ||
| 102 | } | 95 | } |
| 103 | switch (attr) { | 96 | switch (attr) { |
| 104 | case IR::Attribute::PointSize: | 97 | case IR::Attribute::PointSize: |
| @@ -111,14 +104,6 @@ std::optional<OutAttr> OutputAttrPointer(EmitContext& ctx, IR::Attribute attr) { | |||
| 111 | const Id element_id{ctx.Const(element)}; | 104 | const Id element_id{ctx.Const(element)}; |
| 112 | return OutputAccessChain(ctx, ctx.output_f32, ctx.output_position, element_id); | 105 | return OutputAccessChain(ctx, ctx.output_f32, ctx.output_position, element_id); |
| 113 | } | 106 | } |
| 114 | case IR::Attribute::ColorFrontDiffuseR: | ||
| 115 | case IR::Attribute::ColorFrontDiffuseG: | ||
| 116 | case IR::Attribute::ColorFrontDiffuseB: | ||
| 117 | case IR::Attribute::ColorFrontDiffuseA: { | ||
| 118 | const u32 element{static_cast<u32>(attr) % 4}; | ||
| 119 | const Id element_id{ctx.Const(element)}; | ||
| 120 | return OutputAccessChain(ctx, ctx.output_f32, ctx.output_front_color, element_id); | ||
| 121 | } | ||
| 122 | case IR::Attribute::ClipDistance0: | 107 | case IR::Attribute::ClipDistance0: |
| 123 | case IR::Attribute::ClipDistance1: | 108 | case IR::Attribute::ClipDistance1: |
| 124 | case IR::Attribute::ClipDistance2: | 109 | case IR::Attribute::ClipDistance2: |
| @@ -341,11 +326,17 @@ Id EmitGetAttribute(EmitContext& ctx, IR::Attribute attr, Id vertex) { | |||
| 341 | const Id value{ctx.OpLoad(type->id, pointer)}; | 326 | const Id value{ctx.OpLoad(type->id, pointer)}; |
| 342 | return type->needs_cast ? ctx.OpBitcast(ctx.F32[1], value) : value; | 327 | return type->needs_cast ? ctx.OpBitcast(ctx.F32[1], value) : value; |
| 343 | } | 328 | } |
| 344 | if (IsFixedFncTexture(attr)) { | 329 | if (IsLegacyAttribute(attr)) { |
| 345 | const u32 index{FixedFncTextureAttributeIndex(attr)}; | 330 | if (attr == IR::Attribute::FogCoordinate) { |
| 346 | const Id attr_id{ctx.input_fixed_fnc_textures[index]}; | 331 | const Id attr_ptr{AttrPointer(ctx, ctx.input_f32, vertex, |
| 347 | const Id attr_ptr{AttrPointer(ctx, ctx.input_f32, vertex, attr_id, ctx.Const(element))}; | 332 | ctx.InputLegacyAttribute(attr), ctx.Const(0u))}; |
| 348 | return ctx.OpLoad(ctx.F32[1], attr_ptr); | 333 | return ctx.OpLoad(ctx.F32[1], attr_ptr); |
| 334 | } else { | ||
| 335 | const Id element_id{ctx.Const(element)}; | ||
| 336 | const Id attr_ptr{AttrPointer(ctx, ctx.input_f32, vertex, | ||
| 337 | ctx.InputLegacyAttribute(attr), element_id)}; | ||
| 338 | return ctx.OpLoad(ctx.F32[1], attr_ptr); | ||
| 339 | } | ||
| 349 | } | 340 | } |
| 350 | switch (attr) { | 341 | switch (attr) { |
| 351 | case IR::Attribute::PrimitiveId: | 342 | case IR::Attribute::PrimitiveId: |
| @@ -356,13 +347,6 @@ Id EmitGetAttribute(EmitContext& ctx, IR::Attribute attr, Id vertex) { | |||
| 356 | case IR::Attribute::PositionW: | 347 | case IR::Attribute::PositionW: |
| 357 | return ctx.OpLoad(ctx.F32[1], AttrPointer(ctx, ctx.input_f32, vertex, ctx.input_position, | 348 | return ctx.OpLoad(ctx.F32[1], AttrPointer(ctx, ctx.input_f32, vertex, ctx.input_position, |
| 358 | ctx.Const(element))); | 349 | ctx.Const(element))); |
| 359 | case IR::Attribute::ColorFrontDiffuseR: | ||
| 360 | case IR::Attribute::ColorFrontDiffuseG: | ||
| 361 | case IR::Attribute::ColorFrontDiffuseB: | ||
| 362 | case IR::Attribute::ColorFrontDiffuseA: { | ||
| 363 | return ctx.OpLoad(ctx.F32[1], AttrPointer(ctx, ctx.input_f32, vertex, ctx.input_front_color, | ||
| 364 | ctx.Const(element))); | ||
| 365 | } | ||
| 366 | case IR::Attribute::InstanceId: | 350 | case IR::Attribute::InstanceId: |
| 367 | if (ctx.profile.support_vertex_instance_id) { | 351 | if (ctx.profile.support_vertex_instance_id) { |
| 368 | return ctx.OpBitcast(ctx.F32[1], ctx.OpLoad(ctx.U32[1], ctx.instance_id)); | 352 | return ctx.OpBitcast(ctx.F32[1], ctx.OpLoad(ctx.U32[1], ctx.instance_id)); |
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 5c767e8f2..4e5552d2a 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp | |||
| @@ -299,6 +299,8 @@ GMainWindow::GMainWindow() | |||
| 299 | SDL_EnableScreenSaver(); | 299 | SDL_EnableScreenSaver(); |
| 300 | #endif | 300 | #endif |
| 301 | 301 | ||
| 302 | Common::Log::Start(); | ||
| 303 | |||
| 302 | QStringList args = QApplication::arguments(); | 304 | QStringList args = QApplication::arguments(); |
| 303 | 305 | ||
| 304 | if (args.size() < 2) { | 306 | if (args.size() < 2) { |