diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.cpp | 29 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_decompiler.cpp | 20 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_state.h | 3 |
3 files changed, 19 insertions, 33 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index de7b7ce93..fbb9bbac1 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp | |||
| @@ -940,12 +940,9 @@ void RasterizerOpenGL::SetupGlobalMemory(u32 binding, const GLShader::GlobalMemo | |||
| 940 | 940 | ||
| 941 | void RasterizerOpenGL::SetupDrawTextures(std::size_t stage_index, const Shader& shader) { | 941 | void RasterizerOpenGL::SetupDrawTextures(std::size_t stage_index, const Shader& shader) { |
| 942 | MICROPROFILE_SCOPE(OpenGL_Texture); | 942 | MICROPROFILE_SCOPE(OpenGL_Texture); |
| 943 | const auto& gpu = system.GPU(); | 943 | const auto& maxwell3d = system.GPU().Maxwell3D(); |
| 944 | const auto& maxwell3d = gpu.Maxwell3D(); | ||
| 945 | const auto& entries = shader->GetShaderEntries().samplers; | ||
| 946 | |||
| 947 | u32 binding = device.GetBaseBindings(stage_index).sampler; | 944 | u32 binding = device.GetBaseBindings(stage_index).sampler; |
| 948 | for (const auto& entry : entries) { | 945 | for (const auto& entry : shader->GetShaderEntries().samplers) { |
| 949 | const auto shader_type = static_cast<Tegra::Engines::ShaderType>(stage_index); | 946 | const auto shader_type = static_cast<Tegra::Engines::ShaderType>(stage_index); |
| 950 | const auto texture = GetTextureInfo(maxwell3d, entry, shader_type); | 947 | const auto texture = GetTextureInfo(maxwell3d, entry, shader_type); |
| 951 | SetupTexture(binding++, texture, entry); | 948 | SetupTexture(binding++, texture, entry); |
| @@ -955,10 +952,8 @@ void RasterizerOpenGL::SetupDrawTextures(std::size_t stage_index, const Shader& | |||
| 955 | void RasterizerOpenGL::SetupComputeTextures(const Shader& kernel) { | 952 | void RasterizerOpenGL::SetupComputeTextures(const Shader& kernel) { |
| 956 | MICROPROFILE_SCOPE(OpenGL_Texture); | 953 | MICROPROFILE_SCOPE(OpenGL_Texture); |
| 957 | const auto& compute = system.GPU().KeplerCompute(); | 954 | const auto& compute = system.GPU().KeplerCompute(); |
| 958 | const auto& entries = kernel->GetShaderEntries().samplers; | ||
| 959 | |||
| 960 | u32 binding = 0; | 955 | u32 binding = 0; |
| 961 | for (const auto& entry : entries) { | 956 | for (const auto& entry : kernel->GetShaderEntries().samplers) { |
| 962 | const auto texture = GetTextureInfo(compute, entry, Tegra::Engines::ShaderType::Compute); | 957 | const auto texture = GetTextureInfo(compute, entry, Tegra::Engines::ShaderType::Compute); |
| 963 | SetupTexture(binding++, texture, entry); | 958 | SetupTexture(binding++, texture, entry); |
| 964 | } | 959 | } |
| @@ -987,26 +982,20 @@ void RasterizerOpenGL::SetupTexture(u32 binding, const Tegra::Texture::FullTextu | |||
| 987 | 982 | ||
| 988 | void RasterizerOpenGL::SetupDrawImages(std::size_t stage_index, const Shader& shader) { | 983 | void RasterizerOpenGL::SetupDrawImages(std::size_t stage_index, const Shader& shader) { |
| 989 | const auto& maxwell3d = system.GPU().Maxwell3D(); | 984 | const auto& maxwell3d = system.GPU().Maxwell3D(); |
| 990 | const auto& entries = shader->GetShaderEntries().images; | 985 | u32 binding = device.GetBaseBindings(stage_index).image; |
| 991 | 986 | for (const auto& entry : shader->GetShaderEntries().images) { | |
| 992 | const auto num_entries = static_cast<u32>(entries.size()); | ||
| 993 | for (u32 bindpoint = 0; bindpoint < num_entries; ++bindpoint) { | ||
| 994 | const auto& entry = entries[bindpoint]; | ||
| 995 | const auto shader_type = static_cast<Tegra::Engines::ShaderType>(stage_index); | 987 | const auto shader_type = static_cast<Tegra::Engines::ShaderType>(stage_index); |
| 996 | const auto tic = GetTextureInfo(maxwell3d, entry, shader_type).tic; | 988 | const auto tic = GetTextureInfo(maxwell3d, entry, shader_type).tic; |
| 997 | SetupImage(bindpoint, tic, entry); | 989 | SetupImage(binding++, tic, entry); |
| 998 | } | 990 | } |
| 999 | } | 991 | } |
| 1000 | 992 | ||
| 1001 | void RasterizerOpenGL::SetupComputeImages(const Shader& shader) { | 993 | void RasterizerOpenGL::SetupComputeImages(const Shader& shader) { |
| 1002 | const auto& compute = system.GPU().KeplerCompute(); | 994 | const auto& compute = system.GPU().KeplerCompute(); |
| 1003 | const auto& entries = shader->GetShaderEntries().images; | 995 | u32 binding = 0; |
| 1004 | 996 | for (const auto& entry : shader->GetShaderEntries().images) { | |
| 1005 | const auto num_entries = static_cast<u32>(entries.size()); | ||
| 1006 | for (u32 bindpoint = 0; bindpoint < num_entries; ++bindpoint) { | ||
| 1007 | const auto& entry = entries[bindpoint]; | ||
| 1008 | const auto tic = GetTextureInfo(compute, entry, Tegra::Engines::ShaderType::Compute).tic; | 997 | const auto tic = GetTextureInfo(compute, entry, Tegra::Engines::ShaderType::Compute).tic; |
| 1009 | SetupImage(bindpoint, tic, entry); | 998 | SetupImage(binding++, tic, entry); |
| 1010 | } | 999 | } |
| 1011 | } | 1000 | } |
| 1012 | 1001 | ||
diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp index 040370c83..b17c4e703 100644 --- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp +++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp | |||
| @@ -650,12 +650,10 @@ private: | |||
| 650 | } | 650 | } |
| 651 | 651 | ||
| 652 | void DeclareSamplers() { | 652 | void DeclareSamplers() { |
| 653 | const auto& samplers = ir.GetSamplers(); | 653 | u32 binding = device.GetBaseBindings(stage).sampler; |
| 654 | for (const auto& sampler : samplers) { | 654 | for (const auto& sampler : ir.GetSamplers()) { |
| 655 | const std::string name = GetSampler(sampler); | 655 | const std::string name = GetSampler(sampler); |
| 656 | 656 | const std::string description = fmt::format("layout (binding = {}) uniform", binding++); | |
| 657 | const u32 binding = device.GetBaseBindings(stage).sampler + sampler.GetIndex(); | ||
| 658 | const std::string description = fmt::format("layout (binding = {}) uniform", binding); | ||
| 659 | 657 | ||
| 660 | std::string sampler_type = [&]() { | 658 | std::string sampler_type = [&]() { |
| 661 | if (sampler.IsBuffer()) { | 659 | if (sampler.IsBuffer()) { |
| @@ -684,7 +682,7 @@ private: | |||
| 684 | 682 | ||
| 685 | code.AddLine("{} {} {};", description, sampler_type, name); | 683 | code.AddLine("{} {} {};", description, sampler_type, name); |
| 686 | } | 684 | } |
| 687 | if (!samplers.empty()) { | 685 | if (!ir.GetSamplers().empty()) { |
| 688 | code.AddNewLine(); | 686 | code.AddNewLine(); |
| 689 | } | 687 | } |
| 690 | } | 688 | } |
| @@ -724,8 +722,8 @@ private: | |||
| 724 | } | 722 | } |
| 725 | 723 | ||
| 726 | void DeclareImages() { | 724 | void DeclareImages() { |
| 727 | const auto& images{ir.GetImages()}; | 725 | u32 binding = device.GetBaseBindings(stage).image; |
| 728 | for (const auto& image : images) { | 726 | for (const auto& image : ir.GetImages()) { |
| 729 | std::string qualifier = "coherent volatile"; | 727 | std::string qualifier = "coherent volatile"; |
| 730 | if (image.IsRead() && !image.IsWritten()) { | 728 | if (image.IsRead() && !image.IsWritten()) { |
| 731 | qualifier += " readonly"; | 729 | qualifier += " readonly"; |
| @@ -733,14 +731,12 @@ private: | |||
| 733 | qualifier += " writeonly"; | 731 | qualifier += " writeonly"; |
| 734 | } | 732 | } |
| 735 | 733 | ||
| 736 | const u32 binding = device.GetBaseBindings(stage).image + image.GetIndex(); | ||
| 737 | |||
| 738 | const char* format = image.IsAtomic() ? "r32ui, " : ""; | 734 | const char* format = image.IsAtomic() ? "r32ui, " : ""; |
| 739 | const char* type_declaration = GetImageTypeDeclaration(image.GetType()); | 735 | const char* type_declaration = GetImageTypeDeclaration(image.GetType()); |
| 740 | code.AddLine("layout ({}binding = {}) {} uniform uimage{} {};", format, binding, | 736 | code.AddLine("layout ({}binding = {}) {} uniform uimage{} {};", format, binding++, |
| 741 | qualifier, type_declaration, GetImage(image)); | 737 | qualifier, type_declaration, GetImage(image)); |
| 742 | } | 738 | } |
| 743 | if (!images.empty()) { | 739 | if (!ir.GetImages().empty()) { |
| 744 | code.AddNewLine(); | 740 | code.AddNewLine(); |
| 745 | } | 741 | } |
| 746 | } | 742 | } |
diff --git a/src/video_core/renderer_opengl/gl_state.h b/src/video_core/renderer_opengl/gl_state.h index fd53eb81a..e53c2c5f2 100644 --- a/src/video_core/renderer_opengl/gl_state.h +++ b/src/video_core/renderer_opengl/gl_state.h | |||
| @@ -97,9 +97,10 @@ public: | |||
| 97 | } logic_op; | 97 | } logic_op; |
| 98 | 98 | ||
| 99 | static constexpr std::size_t NumSamplers = 32 * 5; | 99 | static constexpr std::size_t NumSamplers = 32 * 5; |
| 100 | static constexpr std::size_t NumImages = 8 * 5; | ||
| 100 | std::array<GLuint, NumSamplers> textures = {}; | 101 | std::array<GLuint, NumSamplers> textures = {}; |
| 101 | std::array<GLuint, NumSamplers> samplers = {}; | 102 | std::array<GLuint, NumSamplers> samplers = {}; |
| 102 | std::array<GLuint, Tegra::Engines::Maxwell3D::Regs::NumImages> images = {}; | 103 | std::array<GLuint, NumImages> images = {}; |
| 103 | 104 | ||
| 104 | struct { | 105 | struct { |
| 105 | GLuint read_framebuffer = 0; // GL_READ_FRAMEBUFFER_BINDING | 106 | GLuint read_framebuffer = 0; // GL_READ_FRAMEBUFFER_BINDING |