diff options
Diffstat (limited to 'src/shader_recompiler/backend/glsl')
4 files changed, 22 insertions, 29 deletions
diff --git a/src/shader_recompiler/backend/glsl/emit_context.cpp b/src/shader_recompiler/backend/glsl/emit_context.cpp index bd40356a1..14c009535 100644 --- a/src/shader_recompiler/backend/glsl/emit_context.cpp +++ b/src/shader_recompiler/backend/glsl/emit_context.cpp | |||
| @@ -327,11 +327,12 @@ EmitContext::EmitContext(IR::Program& program, Bindings& bindings, const Profile | |||
| 327 | 327 | ||
| 328 | for (size_t index = 0; index < info.input_generics.size(); ++index) { | 328 | for (size_t index = 0; index < info.input_generics.size(); ++index) { |
| 329 | const auto& generic{info.input_generics[index]}; | 329 | const auto& generic{info.input_generics[index]}; |
| 330 | if (generic.used) { | 330 | if (!generic.used || !runtime_info.previous_stage_stores_generic[index]) { |
| 331 | header += fmt::format("layout(location={}){}in vec4 in_attr{}{};", index, | 331 | continue; |
| 332 | InterpDecorator(generic.interpolation), index, | ||
| 333 | InputArrayDecorator(stage)); | ||
| 334 | } | 332 | } |
| 333 | header += | ||
| 334 | fmt::format("layout(location={}){}in vec4 in_attr{}{};", index, | ||
| 335 | InterpDecorator(generic.interpolation), index, InputArrayDecorator(stage)); | ||
| 335 | } | 336 | } |
| 336 | for (size_t index = 0; index < info.uses_patches.size(); ++index) { | 337 | for (size_t index = 0; index < info.uses_patches.size(); ++index) { |
| 337 | if (!info.uses_patches[index]) { | 338 | if (!info.uses_patches[index]) { |
| @@ -349,10 +350,10 @@ EmitContext::EmitContext(IR::Program& program, Bindings& bindings, const Profile | |||
| 349 | } | 350 | } |
| 350 | } | 351 | } |
| 351 | for (size_t index = 0; index < info.stores_generics.size(); ++index) { | 352 | for (size_t index = 0; index < info.stores_generics.size(); ++index) { |
| 352 | // TODO: Properly resolve attribute issues | 353 | if (!info.stores_generics[index]) { |
| 353 | if (info.stores_generics[index] || StageInitializesVaryings()) { | 354 | continue; |
| 354 | DefineGenericOutput(index, program.invocations); | ||
| 355 | } | 355 | } |
| 356 | DefineGenericOutput(index, program.invocations); | ||
| 356 | } | 357 | } |
| 357 | DefineConstantBuffers(bindings); | 358 | DefineConstantBuffers(bindings); |
| 358 | DefineStorageBuffers(bindings); | 359 | DefineStorageBuffers(bindings); |
| @@ -362,17 +363,6 @@ EmitContext::EmitContext(IR::Program& program, Bindings& bindings, const Profile | |||
| 362 | DefineConstants(); | 363 | DefineConstants(); |
| 363 | } | 364 | } |
| 364 | 365 | ||
| 365 | bool EmitContext::StageInitializesVaryings() const noexcept { | ||
| 366 | switch (stage) { | ||
| 367 | case Stage::VertexA: | ||
| 368 | case Stage::VertexB: | ||
| 369 | case Stage::Geometry: | ||
| 370 | return true; | ||
| 371 | default: | ||
| 372 | return false; | ||
| 373 | } | ||
| 374 | } | ||
| 375 | |||
| 376 | void EmitContext::SetupExtensions() { | 366 | void EmitContext::SetupExtensions() { |
| 377 | if (info.uses_shadow_lod && profile.support_gl_texture_shadow_lod) { | 367 | if (info.uses_shadow_lod && profile.support_gl_texture_shadow_lod) { |
| 378 | header += "#extension GL_EXT_texture_shadow_lod : enable\n"; | 368 | header += "#extension GL_EXT_texture_shadow_lod : enable\n"; |
diff --git a/src/shader_recompiler/backend/glsl/emit_context.h b/src/shader_recompiler/backend/glsl/emit_context.h index 4a50556e1..8fa87c02c 100644 --- a/src/shader_recompiler/backend/glsl/emit_context.h +++ b/src/shader_recompiler/backend/glsl/emit_context.h | |||
| @@ -136,8 +136,6 @@ public: | |||
| 136 | code += '\n'; | 136 | code += '\n'; |
| 137 | } | 137 | } |
| 138 | 138 | ||
| 139 | [[nodiscard]] bool StageInitializesVaryings() const noexcept; | ||
| 140 | |||
| 141 | std::string header; | 139 | std::string header; |
| 142 | std::string code; | 140 | std::string code; |
| 143 | VarAlloc var_alloc; | 141 | VarAlloc var_alloc; |
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 a241d18fe..663ff3753 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 | |||
| @@ -8,6 +8,7 @@ | |||
| 8 | #include "shader_recompiler/backend/glsl/emit_glsl_instructions.h" | 8 | #include "shader_recompiler/backend/glsl/emit_glsl_instructions.h" |
| 9 | #include "shader_recompiler/frontend/ir/value.h" | 9 | #include "shader_recompiler/frontend/ir/value.h" |
| 10 | #include "shader_recompiler/profile.h" | 10 | #include "shader_recompiler/profile.h" |
| 11 | #include "shader_recompiler/runtime_info.h" | ||
| 11 | 12 | ||
| 12 | namespace Shader::Backend::GLSL { | 13 | namespace Shader::Backend::GLSL { |
| 13 | namespace { | 14 | namespace { |
| @@ -179,6 +180,10 @@ void EmitGetAttribute(EmitContext& ctx, IR::Inst& inst, IR::Attribute attr, | |||
| 179 | const char swizzle{"xyzw"[element]}; | 180 | const char swizzle{"xyzw"[element]}; |
| 180 | if (IR::IsGeneric(attr)) { | 181 | if (IR::IsGeneric(attr)) { |
| 181 | const u32 index{IR::GenericAttributeIndex(attr)}; | 182 | const u32 index{IR::GenericAttributeIndex(attr)}; |
| 183 | if (!ctx.runtime_info.previous_stage_stores_generic[index]) { | ||
| 184 | ctx.AddF32("{}=0.f;", inst, attr); | ||
| 185 | return; | ||
| 186 | } | ||
| 182 | ctx.AddF32("{}=in_attr{}{}.{};", inst, index, InputVertexIndex(ctx, vertex), swizzle); | 187 | ctx.AddF32("{}=in_attr{}{}.{};", inst, index, InputVertexIndex(ctx, vertex), swizzle); |
| 183 | return; | 188 | return; |
| 184 | } | 189 | } |
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_special.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_special.cpp index f8e8aaa67..1a2d3dcea 100644 --- a/src/shader_recompiler/backend/glsl/emit_glsl_special.cpp +++ b/src/shader_recompiler/backend/glsl/emit_glsl_special.cpp | |||
| @@ -12,11 +12,12 @@ | |||
| 12 | 12 | ||
| 13 | namespace Shader::Backend::GLSL { | 13 | namespace Shader::Backend::GLSL { |
| 14 | namespace { | 14 | namespace { |
| 15 | void InitializeVaryings(EmitContext& ctx) { | 15 | void InitializeOutputVaryings(EmitContext& ctx) { |
| 16 | ctx.Add("gl_Position=vec4(0,0,0,1);"); | 16 | if (ctx.stage == Stage::VertexB || ctx.stage == Stage::Geometry) { |
| 17 | // TODO: Properly resolve attribute issues | 17 | ctx.Add("gl_Position=vec4(0,0,0,1);"); |
| 18 | for (size_t index = 0; index < ctx.info.stores_generics.size() / 2; ++index) { | 18 | } |
| 19 | if (!ctx.info.stores_generics[index]) { | 19 | for (size_t index = 0; index < 16; ++index) { |
| 20 | if (ctx.info.stores_generics[index]) { | ||
| 20 | ctx.Add("out_attr{}=vec4(0,0,0,1);", index); | 21 | ctx.Add("out_attr{}=vec4(0,0,0,1);", index); |
| 21 | } | 22 | } |
| 22 | } | 23 | } |
| @@ -56,9 +57,8 @@ void EmitPhiMove(EmitContext& ctx, const IR::Value& phi_value, const IR::Value& | |||
| 56 | } | 57 | } |
| 57 | 58 | ||
| 58 | void EmitPrologue(EmitContext& ctx) { | 59 | void EmitPrologue(EmitContext& ctx) { |
| 59 | if (ctx.StageInitializesVaryings()) { | 60 | InitializeOutputVaryings(ctx); |
| 60 | InitializeVaryings(ctx); | 61 | |
| 61 | } | ||
| 62 | if (ctx.stage == Stage::Fragment && ctx.profile.need_declared_frag_colors) { | 62 | if (ctx.stage == Stage::Fragment && ctx.profile.need_declared_frag_colors) { |
| 63 | for (size_t index = 0; index < ctx.info.stores_frag_color.size(); ++index) { | 63 | for (size_t index = 0; index < ctx.info.stores_frag_color.size(); ++index) { |
| 64 | if (ctx.info.stores_frag_color[index]) { | 64 | if (ctx.info.stores_frag_color[index]) { |
| @@ -73,7 +73,7 @@ void EmitEpilogue(EmitContext&) {} | |||
| 73 | 73 | ||
| 74 | void EmitEmitVertex(EmitContext& ctx, const IR::Value& stream) { | 74 | void EmitEmitVertex(EmitContext& ctx, const IR::Value& stream) { |
| 75 | ctx.Add("EmitStreamVertex(int({}));", ctx.var_alloc.Consume(stream)); | 75 | ctx.Add("EmitStreamVertex(int({}));", ctx.var_alloc.Consume(stream)); |
| 76 | InitializeVaryings(ctx); | 76 | InitializeOutputVaryings(ctx); |
| 77 | } | 77 | } |
| 78 | 78 | ||
| 79 | void EmitEndPrimitive(EmitContext& ctx, const IR::Value& stream) { | 79 | void EmitEndPrimitive(EmitContext& ctx, const IR::Value& stream) { |