summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorameerj <52414509+ameerj@users.noreply.github.com>2021-06-02 06:48:49 +0200
committerameerj <52414509+ameerj@users.noreply.github.com>2021-07-23 03:51:37 +0200
commit6577a63d368afa57d5f29df40e524af30eaabffa (patch)
treef7f8395570364499933551332c4c9c92c00d650d
parentglsl: Implement transform feedback (diff)
downloadyuzu-6577a63d368afa57d5f29df40e524af30eaabffa.tar
yuzu-6577a63d368afa57d5f29df40e524af30eaabffa.tar.gz
yuzu-6577a63d368afa57d5f29df40e524af30eaabffa.tar.bz2
yuzu-6577a63d368afa57d5f29df40e524af30eaabffa.tar.lz
yuzu-6577a63d368afa57d5f29df40e524af30eaabffa.tar.xz
yuzu-6577a63d368afa57d5f29df40e524af30eaabffa.tar.zst
yuzu-6577a63d368afa57d5f29df40e524af30eaabffa.zip
-rw-r--r--src/shader_recompiler/backend/glsl/emit_context.cpp18
-rw-r--r--src/shader_recompiler/backend/glsl/emit_context.h1
-rw-r--r--src/shader_recompiler/backend/glsl/emit_glsl_context_get_set.cpp5
-rw-r--r--src/shader_recompiler/profile.h1
-rw-r--r--src/video_core/renderer_opengl/gl_shader_cache.cpp1
5 files changed, 18 insertions, 8 deletions
diff --git a/src/shader_recompiler/backend/glsl/emit_context.cpp b/src/shader_recompiler/backend/glsl/emit_context.cpp
index 58355d5e3..846d38bfc 100644
--- a/src/shader_recompiler/backend/glsl/emit_context.cpp
+++ b/src/shader_recompiler/backend/glsl/emit_context.cpp
@@ -148,23 +148,24 @@ std::string_view OutputPrimitive(OutputTopology topology) {
throw InvalidArgument("Invalid output topology {}", topology);
}
-void SetupOutPerVertex(Stage stage, const Info& info, std::string& header) {
- if (!StoresPerVertexAttributes(stage)) {
+void SetupOutPerVertex(EmitContext& ctx, std::string& header) {
+ if (!StoresPerVertexAttributes(ctx.stage)) {
return;
}
header += "out gl_PerVertex{";
header += "vec4 gl_Position;";
- if (info.stores_point_size) {
+ if (ctx.info.stores_point_size) {
header += "float gl_PointSize;";
}
- if (info.stores_clip_distance) {
+ if (ctx.info.stores_clip_distance) {
header += "float gl_ClipDistance[];";
}
- if (info.stores_viewport_index && stage != Stage::Geometry) {
+ if (ctx.info.stores_viewport_index && ctx.supports_viewport_layer &&
+ ctx.stage != Stage::Geometry) {
header += "int gl_ViewportIndex;";
}
header += "};\n";
- if (info.stores_viewport_index && stage == Stage::Geometry) {
+ if (ctx.info.stores_viewport_index && ctx.stage == Stage::Geometry) {
header += "out int gl_ViewportIndex;";
}
}
@@ -173,6 +174,7 @@ void SetupOutPerVertex(Stage stage, const Info& info, std::string& header) {
EmitContext::EmitContext(IR::Program& program, Bindings& bindings, const Profile& profile_,
const RuntimeInfo& runtime_info_)
: info{program.info}, profile{profile_}, runtime_info{runtime_info_} {
+ supports_viewport_layer = profile.support_gl_vertex_viewport_layer;
SetupExtensions(header);
stage = program.stage;
switch (program.stage) {
@@ -206,7 +208,7 @@ EmitContext::EmitContext(IR::Program& program, Bindings& bindings, const Profile
program.workgroup_size[2]);
break;
}
- SetupOutPerVertex(stage, info, header);
+ SetupOutPerVertex(*this, header);
for (size_t index = 0; index < info.input_generics.size(); ++index) {
const auto& generic{info.input_generics[index]};
if (generic.used) {
@@ -276,7 +278,7 @@ void EmitContext::SetupExtensions(std::string&) {
header += "#extension GL_ARB_gpu_shader_int64 : enable\n";
}
}
- if (info.stores_viewport_index && stage != Stage::Geometry) {
+ if (info.stores_viewport_index && supports_viewport_layer && stage != Stage::Geometry) {
header += "#extension GL_ARB_shader_viewport_layer_array : enable\n";
}
}
diff --git a/src/shader_recompiler/backend/glsl/emit_context.h b/src/shader_recompiler/backend/glsl/emit_context.h
index 5d48675e6..26a76f8a3 100644
--- a/src/shader_recompiler/backend/glsl/emit_context.h
+++ b/src/shader_recompiler/backend/glsl/emit_context.h
@@ -159,6 +159,7 @@ public:
bool uses_y_direction{};
bool uses_cc_carry{};
+ bool supports_viewport_layer{};
private:
void SetupExtensions(std::string& header);
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_context_get_set.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_context_get_set.cpp
index c48492a17..ebaf50abd 100644
--- a/src/shader_recompiler/backend/glsl/emit_glsl_context_get_set.cpp
+++ b/src/shader_recompiler/backend/glsl/emit_glsl_context_get_set.cpp
@@ -226,6 +226,11 @@ void EmitSetAttribute(EmitContext& ctx, IR::Attribute attr, std::string_view val
ctx.Add("gl_Position.{}={};", swizzle, value);
break;
case IR::Attribute::ViewportIndex:
+ if (ctx.stage != Stage::Geometry && !ctx.supports_viewport_layer) {
+ // LOG_WARNING(..., "Shader stores viewport index but device does not support viewport
+ // layer extension");
+ break;
+ }
ctx.Add("gl_ViewportIndex=floatBitsToInt({});", value);
break;
case IR::Attribute::ClipDistance0:
diff --git a/src/shader_recompiler/profile.h b/src/shader_recompiler/profile.h
index 5d269368a..420117132 100644
--- a/src/shader_recompiler/profile.h
+++ b/src/shader_recompiler/profile.h
@@ -85,6 +85,7 @@ struct Profile {
bool support_derivative_control{};
bool support_gl_nv_gpu_shader_5{};
bool support_gl_amd_gpu_shader_half_float{};
+ bool support_gl_vertex_viewport_layer{};
bool warp_size_potentially_larger_than_guest{};
diff --git a/src/video_core/renderer_opengl/gl_shader_cache.cpp b/src/video_core/renderer_opengl/gl_shader_cache.cpp
index 0a1ba363b..77681594a 100644
--- a/src/video_core/renderer_opengl/gl_shader_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_shader_cache.cpp
@@ -225,6 +225,7 @@ ShaderCache::ShaderCache(RasterizerOpenGL& rasterizer_, Core::Frontend::EmuWindo
.support_derivative_control = device.HasDerivativeControl(),
.support_gl_nv_gpu_shader_5 = device.HasNvGpuShader5(),
.support_gl_amd_gpu_shader_half_float = device.HasAmdShaderHalfFloat(),
+ .support_gl_vertex_viewport_layer = device.HasVertexViewportLayer(),
.warp_size_potentially_larger_than_guest = device.IsWarpSizePotentiallyLargerThanGuest(),