diff options
| author | 2019-05-02 16:06:56 -0300 | |
|---|---|---|
| committer | 2019-05-02 21:46:37 -0300 | |
| commit | 5321cdd276830699c50053dd464e66680f4c8a64 (patch) | |
| tree | 05090e35db3d4d8686685b13172ee9526f0d4da1 /src | |
| parent | shader_ir/memory: Assert on non-32 bits ALD.PHYS (diff) | |
| download | yuzu-5321cdd276830699c50053dd464e66680f4c8a64.tar.gz yuzu-5321cdd276830699c50053dd464e66680f4c8a64.tar.xz yuzu-5321cdd276830699c50053dd464e66680f4c8a64.zip | |
gl_shader_decompiler: Skip physical unused attributes
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_decompiler.cpp | 45 |
1 files changed, 27 insertions, 18 deletions
diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp index 52552333f..da925372c 100644 --- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp +++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp | |||
| @@ -310,30 +310,28 @@ private: | |||
| 310 | } | 310 | } |
| 311 | 311 | ||
| 312 | std::string GetInputFlags(AttributeUse attribute) { | 312 | std::string GetInputFlags(AttributeUse attribute) { |
| 313 | std::string out; | ||
| 314 | |||
| 315 | switch (attribute) { | 313 | switch (attribute) { |
| 316 | case AttributeUse::Constant: | ||
| 317 | out += "flat "; | ||
| 318 | break; | ||
| 319 | case AttributeUse::ScreenLinear: | ||
| 320 | out += "noperspective "; | ||
| 321 | break; | ||
| 322 | case AttributeUse::Perspective: | 314 | case AttributeUse::Perspective: |
| 323 | // Default, Smooth | 315 | // Default, Smooth |
| 324 | break; | 316 | return {}; |
| 317 | case AttributeUse::Constant: | ||
| 318 | return "flat "; | ||
| 319 | case AttributeUse::ScreenLinear: | ||
| 320 | return "noperspective "; | ||
| 325 | default: | 321 | default: |
| 326 | LOG_CRITICAL(HW_GPU, "Unused attribute being fetched"); | 322 | case AttributeUse::Unused: |
| 327 | UNREACHABLE(); | 323 | UNREACHABLE_MSG("Unused attribute being fetched"); |
| 324 | return {}; | ||
| 325 | UNIMPLEMENTED_MSG("Unknown attribute usage index={}", static_cast<u32>(attribute)); | ||
| 326 | return {}; | ||
| 328 | } | 327 | } |
| 329 | return out; | ||
| 330 | } | 328 | } |
| 331 | 329 | ||
| 332 | void DeclareInputAttributes() { | 330 | void DeclareInputAttributes() { |
| 333 | if (ir.HasPhysicalAttributes()) { | 331 | if (ir.HasPhysicalAttributes()) { |
| 334 | const u32 num_inputs{GetNumPhysicalInputAttributes()}; | 332 | const u32 num_inputs{GetNumPhysicalInputAttributes()}; |
| 335 | for (u32 i = 0; i < num_inputs; ++i) { | 333 | for (u32 i = 0; i < num_inputs; ++i) { |
| 336 | DeclareInputAttribute(ToGenericAttribute(i)); | 334 | DeclareInputAttribute(ToGenericAttribute(i), true); |
| 337 | } | 335 | } |
| 338 | code.AddNewLine(); | 336 | code.AddNewLine(); |
| 339 | return; | 337 | return; |
| @@ -342,14 +340,14 @@ private: | |||
| 342 | const auto& attributes = ir.GetInputAttributes(); | 340 | const auto& attributes = ir.GetInputAttributes(); |
| 343 | for (const auto index : attributes) { | 341 | for (const auto index : attributes) { |
| 344 | if (IsGenericAttribute(index)) { | 342 | if (IsGenericAttribute(index)) { |
| 345 | DeclareInputAttribute(index); | 343 | DeclareInputAttribute(index, false); |
| 346 | } | 344 | } |
| 347 | } | 345 | } |
| 348 | if (!attributes.empty()) | 346 | if (!attributes.empty()) |
| 349 | code.AddNewLine(); | 347 | code.AddNewLine(); |
| 350 | } | 348 | } |
| 351 | 349 | ||
| 352 | void DeclareInputAttribute(Attribute::Index index) { | 350 | void DeclareInputAttribute(Attribute::Index index, bool skip_unused) { |
| 353 | const u32 generic_index{GetGenericAttributeIndex(index)}; | 351 | const u32 generic_index{GetGenericAttributeIndex(index)}; |
| 354 | 352 | ||
| 355 | std::string name{GetInputAttribute(index)}; | 353 | std::string name{GetInputAttribute(index)}; |
| @@ -360,6 +358,9 @@ private: | |||
| 360 | std::string suffix; | 358 | std::string suffix; |
| 361 | if (stage == ShaderStage::Fragment) { | 359 | if (stage == ShaderStage::Fragment) { |
| 362 | const auto input_mode{header.ps.GetAttributeUse(generic_index)}; | 360 | const auto input_mode{header.ps.GetAttributeUse(generic_index)}; |
| 361 | if (skip_unused && input_mode == AttributeUse::Unused) { | ||
| 362 | return; | ||
| 363 | } | ||
| 363 | suffix = GetInputFlags(input_mode); | 364 | suffix = GetInputFlags(input_mode); |
| 364 | } | 365 | } |
| 365 | 366 | ||
| @@ -470,11 +471,19 @@ private: | |||
| 470 | code.AddLine("switch (physical_address) {"); | 471 | code.AddLine("switch (physical_address) {"); |
| 471 | 472 | ||
| 472 | // Just declare generic attributes for now. | 473 | // Just declare generic attributes for now. |
| 473 | const auto num_attributes{static_cast<u32>(GetNumPhysicalAttributes())}; | 474 | const auto num_attributes{static_cast<u32>(GetNumPhysicalInputAttributes())}; |
| 474 | for (u32 index = 0; index < num_attributes; ++index) { | 475 | for (u32 index = 0; index < num_attributes; ++index) { |
| 476 | const auto attribute{ToGenericAttribute(index)}; | ||
| 475 | for (u32 element = 0; element < 4; ++element) { | 477 | for (u32 element = 0; element < 4; ++element) { |
| 476 | code.AddLine(fmt::format("case 0x{:x}: return {};", 0x80 + index * 16 + element * 4, | 478 | constexpr u32 generic_base{0x80}; |
| 477 | ReadAttribute(ToGenericAttribute(index), element))); | 479 | constexpr u32 generic_stride{16}; |
| 480 | constexpr u32 element_stride{4}; | ||
| 481 | const u32 address{generic_base + index * generic_stride + element * element_stride}; | ||
| 482 | |||
| 483 | const bool declared{stage != ShaderStage::Fragment || | ||
| 484 | header.ps.GetAttributeUse(index) != AttributeUse::Unused}; | ||
| 485 | const std::string value{declared ? ReadAttribute(attribute, element) : "0"}; | ||
| 486 | code.AddLine(fmt::format("case 0x{:x}: return {};", address, value)); | ||
| 478 | } | 487 | } |
| 479 | } | 488 | } |
| 480 | 489 | ||