diff options
| author | 2019-06-24 01:56:38 -0300 | |
|---|---|---|
| committer | 2019-06-24 01:56:38 -0300 | |
| commit | b8b05a484a16372b481e1820601cc823543fc58a (patch) | |
| tree | 9c70b2118fa1e229532d1af51adc177db0ce6667 /src | |
| parent | shader_bytecode: Include missing <array> (diff) | |
| download | yuzu-b8b05a484a16372b481e1820601cc823543fc58a.tar.gz yuzu-b8b05a484a16372b481e1820601cc823543fc58a.tar.xz yuzu-b8b05a484a16372b481e1820601cc823543fc58a.zip | |
gl_shader_decompiler: Address feedback
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_decompiler.cpp | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp index ca04d8618..5f2f1510c 100644 --- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp +++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp | |||
| @@ -459,7 +459,7 @@ private: | |||
| 459 | for (const auto& sampler : samplers) { | 459 | for (const auto& sampler : samplers) { |
| 460 | const std::string name{GetSampler(sampler)}; | 460 | const std::string name{GetSampler(sampler)}; |
| 461 | const std::string description{"layout (binding = SAMPLER_BINDING_" + | 461 | const std::string description{"layout (binding = SAMPLER_BINDING_" + |
| 462 | std::to_string(sampler.GetIndex()) + ") uniform "}; | 462 | std::to_string(sampler.GetIndex()) + ") uniform"}; |
| 463 | std::string sampler_type = [&]() { | 463 | std::string sampler_type = [&]() { |
| 464 | switch (sampler.GetType()) { | 464 | switch (sampler.GetType()) { |
| 465 | case Tegra::Shader::TextureType::Texture1D: | 465 | case Tegra::Shader::TextureType::Texture1D: |
| @@ -488,13 +488,13 @@ private: | |||
| 488 | // preprocessor flag and use one or the other from the GPU state. This has to be | 488 | // preprocessor flag and use one or the other from the GPU state. This has to be |
| 489 | // done because shaders don't have enough information to determine the texture type. | 489 | // done because shaders don't have enough information to determine the texture type. |
| 490 | EmitIfdefIsBuffer(sampler); | 490 | EmitIfdefIsBuffer(sampler); |
| 491 | code.AddLine(description + "samplerBuffer " + name + ';'); | 491 | code.AddLine("{} samplerBuffer {};", description, name); |
| 492 | code.AddLine("#else"); | 492 | code.AddLine("#else"); |
| 493 | code.AddLine(description + sampler_type + ' ' + name + ';'); | 493 | code.AddLine("{} {} {};", description, sampler_type, name); |
| 494 | code.AddLine("#endif"); | 494 | code.AddLine("#endif"); |
| 495 | } else { | 495 | } else { |
| 496 | // The other texture types (2D, 3D and cubes) don't have this issue. | 496 | // The other texture types (2D, 3D and cubes) don't have this issue. |
| 497 | code.AddLine(description + sampler_type + ' ' + name + ';'); | 497 | code.AddLine("{} {} {};", description, sampler_type, name); |
| 498 | } | 498 | } |
| 499 | } | 499 | } |
| 500 | if (!samplers.empty()) { | 500 | if (!samplers.empty()) { |
| @@ -557,12 +557,13 @@ private: | |||
| 557 | return "image1D"; | 557 | return "image1D"; |
| 558 | } | 558 | } |
| 559 | }(); | 559 | }(); |
| 560 | code.AddLine("layout (binding = IMAGE_BINDING_" + std::to_string(image.GetIndex()) + | 560 | code.AddLine("layout (binding = IMAGE_BINDING_{}) coherent volatile writeonly uniform " |
| 561 | ") coherent volatile writeonly uniform " + image_type + ' ' + | 561 | "{} {};", |
| 562 | GetImage(image) + ';'); | 562 | image.GetIndex(), image_type, GetImage(image)); |
| 563 | } | 563 | } |
| 564 | if (!images.empty()) | 564 | if (!images.empty()) { |
| 565 | code.AddNewLine(); | 565 | code.AddNewLine(); |
| 566 | } | ||
| 566 | } | 567 | } |
| 567 | 568 | ||
| 568 | void VisitBlock(const NodeBlock& bb) { | 569 | void VisitBlock(const NodeBlock& bb) { |
| @@ -1504,9 +1505,9 @@ private: | |||
| 1504 | 1505 | ||
| 1505 | const std::string tmp{code.GenerateTemporary()}; | 1506 | const std::string tmp{code.GenerateTemporary()}; |
| 1506 | EmitIfdefIsBuffer(meta->sampler); | 1507 | EmitIfdefIsBuffer(meta->sampler); |
| 1507 | code.AddLine("float " + tmp + " = " + expr_buffer + ';'); | 1508 | code.AddLine("float {} = {};", tmp, expr_buffer); |
| 1508 | code.AddLine("#else"); | 1509 | code.AddLine("#else"); |
| 1509 | code.AddLine("float " + tmp + " = " + expr + ';'); | 1510 | code.AddLine("float {} = {};", tmp, expr); |
| 1510 | code.AddLine("#endif"); | 1511 | code.AddLine("#endif"); |
| 1511 | 1512 | ||
| 1512 | return tmp; | 1513 | return tmp; |
| @@ -1860,7 +1861,7 @@ private: | |||
| 1860 | } | 1861 | } |
| 1861 | 1862 | ||
| 1862 | void EmitIfdefIsBuffer(const Sampler& sampler) { | 1863 | void EmitIfdefIsBuffer(const Sampler& sampler) { |
| 1863 | code.AddLine(fmt::format("#ifdef SAMPLER_{}_IS_BUFFER", sampler.GetIndex())); | 1864 | code.AddLine("#ifdef SAMPLER_{}_IS_BUFFER", sampler.GetIndex()); |
| 1864 | } | 1865 | } |
| 1865 | 1866 | ||
| 1866 | std::string GetDeclarationWithSuffix(u32 index, const std::string& name) const { | 1867 | std::string GetDeclarationWithSuffix(u32 index, const std::string& name) const { |