mirror of
				https://git.suyu.dev/suyu/suyu
				synced 2025-11-03 16:39:01 -06:00 
			
		
		
		
	gl_arb_decompiler: Implement an assembly shader decompiler
Emit code compatible with NV_gpu_program5. This should emit code compatible with Fermi, but it wasn't tested on that architecture. Pascal has some issues not present on Turing GPUs.
This commit is contained in:
		@@ -54,6 +54,8 @@ add_library(video_core STATIC
 | 
			
		||||
    rasterizer_interface.h
 | 
			
		||||
    renderer_base.cpp
 | 
			
		||||
    renderer_base.h
 | 
			
		||||
    renderer_opengl/gl_arb_decompiler.cpp
 | 
			
		||||
    renderer_opengl/gl_arb_decompiler.h
 | 
			
		||||
    renderer_opengl/gl_buffer_cache.cpp
 | 
			
		||||
    renderer_opengl/gl_buffer_cache.h
 | 
			
		||||
    renderer_opengl/gl_device.cpp
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										2051
									
								
								src/video_core/renderer_opengl/gl_arb_decompiler.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2051
									
								
								src/video_core/renderer_opengl/gl_arb_decompiler.cpp
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										29
									
								
								src/video_core/renderer_opengl/gl_arb_decompiler.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								src/video_core/renderer_opengl/gl_arb_decompiler.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,29 @@
 | 
			
		||||
// Copyright 2020 yuzu Emulator Project
 | 
			
		||||
// Licensed under GPLv2 or any later version
 | 
			
		||||
// Refer to the license.txt file included.
 | 
			
		||||
 | 
			
		||||
#pragma once
 | 
			
		||||
 | 
			
		||||
#include <string>
 | 
			
		||||
#include <string_view>
 | 
			
		||||
 | 
			
		||||
#include "common/common_types.h"
 | 
			
		||||
 | 
			
		||||
namespace Tegra::Engines {
 | 
			
		||||
enum class ShaderType : u32;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
namespace VideoCommon::Shader {
 | 
			
		||||
class ShaderIR;
 | 
			
		||||
class Registry;
 | 
			
		||||
} // namespace VideoCommon::Shader
 | 
			
		||||
 | 
			
		||||
namespace OpenGL {
 | 
			
		||||
 | 
			
		||||
class Device;
 | 
			
		||||
 | 
			
		||||
std::string DecompileAssemblyShader(const Device& device, const VideoCommon::Shader::ShaderIR& ir,
 | 
			
		||||
                                    const VideoCommon::Shader::Registry& registry,
 | 
			
		||||
                                    Tegra::Engines::ShaderType stage, std::string_view identifier);
 | 
			
		||||
 | 
			
		||||
} // namespace OpenGL
 | 
			
		||||
@@ -213,6 +213,7 @@ Device::Device()
 | 
			
		||||
    has_component_indexing_bug = is_amd;
 | 
			
		||||
    has_precise_bug = TestPreciseBug();
 | 
			
		||||
    has_fast_buffer_sub_data = is_nvidia && !disable_fast_buffer_sub_data;
 | 
			
		||||
    has_nv_viewport_array2 = GLAD_GL_NV_viewport_array2;
 | 
			
		||||
    use_assembly_shaders = Settings::values.use_assembly_shaders && GLAD_GL_NV_gpu_program5 &&
 | 
			
		||||
                           GLAD_GL_NV_compute_program5 && GLAD_GL_NV_transform_feedback &&
 | 
			
		||||
                           GLAD_GL_NV_transform_feedback2;
 | 
			
		||||
 
 | 
			
		||||
@@ -88,6 +88,10 @@ public:
 | 
			
		||||
        return has_fast_buffer_sub_data;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    bool HasNvViewportArray2() const {
 | 
			
		||||
        return has_nv_viewport_array2;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    bool UseAssemblyShaders() const {
 | 
			
		||||
        return use_assembly_shaders;
 | 
			
		||||
    }
 | 
			
		||||
@@ -111,6 +115,7 @@ private:
 | 
			
		||||
    bool has_component_indexing_bug{};
 | 
			
		||||
    bool has_precise_bug{};
 | 
			
		||||
    bool has_fast_buffer_sub_data{};
 | 
			
		||||
    bool has_nv_viewport_array2{};
 | 
			
		||||
    bool use_assembly_shaders{};
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -20,6 +20,7 @@
 | 
			
		||||
#include "video_core/engines/maxwell_3d.h"
 | 
			
		||||
#include "video_core/engines/shader_type.h"
 | 
			
		||||
#include "video_core/memory_manager.h"
 | 
			
		||||
#include "video_core/renderer_opengl/gl_arb_decompiler.h"
 | 
			
		||||
#include "video_core/renderer_opengl/gl_rasterizer.h"
 | 
			
		||||
#include "video_core/renderer_opengl/gl_shader_cache.h"
 | 
			
		||||
#include "video_core/renderer_opengl/gl_shader_decompiler.h"
 | 
			
		||||
@@ -147,7 +148,8 @@ ProgramSharedPtr BuildShader(const Device& device, ShaderType shader_type, u64 u
 | 
			
		||||
    auto program = std::make_shared<ProgramHandle>();
 | 
			
		||||
 | 
			
		||||
    if (device.UseAssemblyShaders()) {
 | 
			
		||||
        const std::string arb = "Not implemented";
 | 
			
		||||
        const std::string arb =
 | 
			
		||||
            DecompileAssemblyShader(device, ir, registry, shader_type, shader_id);
 | 
			
		||||
 | 
			
		||||
        GLuint& arb_prog = program->assembly_program.handle;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user