summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/shader_recompiler/backend/glasm/emit_context.cpp5
-rw-r--r--src/shader_recompiler/backend/glasm/emit_glasm.cpp28
-rw-r--r--src/video_core/renderer_opengl/gl_device.cpp1
-rw-r--r--src/video_core/renderer_opengl/gl_device.h5
-rw-r--r--src/video_core/renderer_opengl/gl_shader_cache.cpp2
5 files changed, 33 insertions, 8 deletions
diff --git a/src/shader_recompiler/backend/glasm/emit_context.cpp b/src/shader_recompiler/backend/glasm/emit_context.cpp
index 80dad9ff3..069c019ad 100644
--- a/src/shader_recompiler/backend/glasm/emit_context.cpp
+++ b/src/shader_recompiler/backend/glasm/emit_context.cpp
@@ -83,13 +83,14 @@ EmitContext::EmitContext(IR::Program& program, Bindings& bindings, const Profile
83 break; 83 break;
84 } 84 }
85 const std::string_view attr_stage{stage == Stage::Fragment ? "fragment" : "vertex"}; 85 const std::string_view attr_stage{stage == Stage::Fragment ? "fragment" : "vertex"};
86 const VaryingState loads{info.loads.mask | info.passthrough.mask};
86 for (size_t index = 0; index < IR::NUM_GENERICS; ++index) { 87 for (size_t index = 0; index < IR::NUM_GENERICS; ++index) {
87 if (info.loads.Generic(index)) { 88 if (loads.Generic(index)) {
88 Add("{}ATTRIB in_attr{}[]={{{}.attrib[{}..{}]}};", 89 Add("{}ATTRIB in_attr{}[]={{{}.attrib[{}..{}]}};",
89 InterpDecorator(info.interpolation[index]), index, attr_stage, index, index); 90 InterpDecorator(info.interpolation[index]), index, attr_stage, index, index);
90 } 91 }
91 } 92 }
92 if (IsInputArray(stage) && info.loads.AnyComponent(IR::Attribute::PositionX)) { 93 if (IsInputArray(stage) && loads.AnyComponent(IR::Attribute::PositionX)) {
93 Add("ATTRIB vertex_position=vertex.position;"); 94 Add("ATTRIB vertex_position=vertex.position;");
94 } 95 }
95 if (info.uses_invocation_id) { 96 if (info.uses_invocation_id) {
diff --git a/src/shader_recompiler/backend/glasm/emit_glasm.cpp b/src/shader_recompiler/backend/glasm/emit_glasm.cpp
index 2b96977b3..64787b353 100644
--- a/src/shader_recompiler/backend/glasm/emit_glasm.cpp
+++ b/src/shader_recompiler/backend/glasm/emit_glasm.cpp
@@ -304,6 +304,9 @@ void SetupOptions(const IR::Program& program, const Profile& profile,
304 header += "OPTION NV_viewport_array2;"; 304 header += "OPTION NV_viewport_array2;";
305 } 305 }
306 } 306 }
307 if (program.is_geometry_passthrough && profile.support_geometry_shader_passthrough) {
308 header += "OPTION NV_geometry_shader_passthrough;";
309 }
307 if (info.uses_typeless_image_reads && profile.support_typeless_image_loads) { 310 if (info.uses_typeless_image_reads && profile.support_typeless_image_loads) {
308 header += "OPTION EXT_shader_image_load_formatted;"; 311 header += "OPTION EXT_shader_image_load_formatted;";
309 } 312 }
@@ -410,11 +413,26 @@ std::string EmitGLASM(const Profile& profile, const RuntimeInfo& runtime_info, I
410 runtime_info.tess_clockwise ? "CW" : "CCW"); 413 runtime_info.tess_clockwise ? "CW" : "CCW");
411 break; 414 break;
412 case Stage::Geometry: 415 case Stage::Geometry:
413 header += fmt::format("PRIMITIVE_IN {};" 416 header += fmt::format("PRIMITIVE_IN {};", InputPrimitive(runtime_info.input_topology));
414 "PRIMITIVE_OUT {};" 417 if (program.is_geometry_passthrough) {
415 "VERTICES_OUT {};", 418 if (profile.support_geometry_shader_passthrough) {
416 InputPrimitive(runtime_info.input_topology), 419 for (size_t index = 0; index < IR::NUM_GENERICS; ++index) {
417 OutputPrimitive(program.output_topology), program.output_vertices); 420 if (program.info.passthrough.Generic(index)) {
421 header += fmt::format("PASSTHROUGH result.attrib[{}];", index);
422 }
423 }
424 if (program.info.passthrough.AnyComponent(IR::Attribute::PositionX)) {
425 header += "PASSTHROUGH result.position;";
426 }
427 } else {
428 LOG_WARNING(Shader_GLASM, "Passthrough geometry program used but not supported");
429 }
430 } else {
431 header +=
432 fmt::format("VERTICES_OUT {};"
433 "PRIMITIVE_OUT {};",
434 program.output_vertices, OutputPrimitive(program.output_topology));
435 }
418 break; 436 break;
419 case Stage::Compute: 437 case Stage::Compute:
420 header += fmt::format("GROUP_SIZE {} {} {};", program.workgroup_size[0], 438 header += fmt::format("GROUP_SIZE {} {} {};", program.workgroup_size[0],
diff --git a/src/video_core/renderer_opengl/gl_device.cpp b/src/video_core/renderer_opengl/gl_device.cpp
index 27be347e6..6818951f2 100644
--- a/src/video_core/renderer_opengl/gl_device.cpp
+++ b/src/video_core/renderer_opengl/gl_device.cpp
@@ -160,6 +160,7 @@ Device::Device() {
160 has_vertex_buffer_unified_memory = GLAD_GL_NV_vertex_buffer_unified_memory; 160 has_vertex_buffer_unified_memory = GLAD_GL_NV_vertex_buffer_unified_memory;
161 has_debugging_tool_attached = IsDebugToolAttached(extensions); 161 has_debugging_tool_attached = IsDebugToolAttached(extensions);
162 has_depth_buffer_float = HasExtension(extensions, "GL_NV_depth_buffer_float"); 162 has_depth_buffer_float = HasExtension(extensions, "GL_NV_depth_buffer_float");
163 has_geometry_shader_passthrough = GLAD_GL_NV_geometry_shader_passthrough;
163 has_nv_gpu_shader_5 = GLAD_GL_NV_gpu_shader5; 164 has_nv_gpu_shader_5 = GLAD_GL_NV_gpu_shader5;
164 has_shader_int64 = HasExtension(extensions, "GL_ARB_gpu_shader_int64"); 165 has_shader_int64 = HasExtension(extensions, "GL_ARB_gpu_shader_int64");
165 has_amd_shader_half_float = GLAD_GL_AMD_gpu_shader_half_float; 166 has_amd_shader_half_float = GLAD_GL_AMD_gpu_shader_half_float;
diff --git a/src/video_core/renderer_opengl/gl_device.h b/src/video_core/renderer_opengl/gl_device.h
index ad7b01b06..45ddf5e01 100644
--- a/src/video_core/renderer_opengl/gl_device.h
+++ b/src/video_core/renderer_opengl/gl_device.h
@@ -120,6 +120,10 @@ public:
120 return has_depth_buffer_float; 120 return has_depth_buffer_float;
121 } 121 }
122 122
123 bool HasGeometryShaderPassthrough() const {
124 return has_geometry_shader_passthrough;
125 }
126
123 bool HasNvGpuShader5() const { 127 bool HasNvGpuShader5() const {
124 return has_nv_gpu_shader_5; 128 return has_nv_gpu_shader_5;
125 } 129 }
@@ -174,6 +178,7 @@ private:
174 bool use_asynchronous_shaders{}; 178 bool use_asynchronous_shaders{};
175 bool use_driver_cache{}; 179 bool use_driver_cache{};
176 bool has_depth_buffer_float{}; 180 bool has_depth_buffer_float{};
181 bool has_geometry_shader_passthrough{};
177 bool has_nv_gpu_shader_5{}; 182 bool has_nv_gpu_shader_5{};
178 bool has_shader_int64{}; 183 bool has_shader_int64{};
179 bool has_amd_shader_half_float{}; 184 bool has_amd_shader_half_float{};
diff --git a/src/video_core/renderer_opengl/gl_shader_cache.cpp b/src/video_core/renderer_opengl/gl_shader_cache.cpp
index 06e39a503..af8e9f44d 100644
--- a/src/video_core/renderer_opengl/gl_shader_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_shader_cache.cpp
@@ -187,7 +187,7 @@ ShaderCache::ShaderCache(RasterizerOpenGL& rasterizer_, Core::Frontend::EmuWindo
187 .support_demote_to_helper_invocation = false, 187 .support_demote_to_helper_invocation = false,
188 .support_int64_atomics = false, 188 .support_int64_atomics = false,
189 .support_derivative_control = device.HasDerivativeControl(), 189 .support_derivative_control = device.HasDerivativeControl(),
190 .support_geometry_shader_passthrough = false, // TODO 190 .support_geometry_shader_passthrough = device.HasGeometryShaderPassthrough(),
191 .support_gl_nv_gpu_shader_5 = device.HasNvGpuShader5(), 191 .support_gl_nv_gpu_shader_5 = device.HasNvGpuShader5(),
192 .support_gl_amd_gpu_shader_half_float = device.HasAmdShaderHalfFloat(), 192 .support_gl_amd_gpu_shader_half_float = device.HasAmdShaderHalfFloat(),
193 .support_gl_texture_shadow_lod = device.HasTextureShadowLod(), 193 .support_gl_texture_shadow_lod = device.HasTextureShadowLod(),