diff options
Diffstat (limited to 'src/shader_recompiler/backend/glsl')
3 files changed, 1 insertions, 103 deletions
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl.cpp b/src/shader_recompiler/backend/glsl/emit_glsl.cpp index 78b2eeaa2..b6b17a330 100644 --- a/src/shader_recompiler/backend/glsl/emit_glsl.cpp +++ b/src/shader_recompiler/backend/glsl/emit_glsl.cpp | |||
| @@ -176,7 +176,7 @@ void EmitCode(EmitContext& ctx, const IR::Program& program) { | |||
| 176 | } | 176 | } |
| 177 | 177 | ||
| 178 | std::string GlslVersionSpecifier(const EmitContext& ctx) { | 178 | std::string GlslVersionSpecifier(const EmitContext& ctx) { |
| 179 | if (ctx.uses_y_direction || ctx.info.stores.Legacy() || ctx.info.loads.Legacy()) { | 179 | if (ctx.uses_y_direction) { |
| 180 | return " compatibility"; | 180 | return " compatibility"; |
| 181 | } | 181 | } |
| 182 | return ""; | 182 | return ""; |
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 1920047f4..6477bd192 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 | |||
| @@ -98,10 +98,6 @@ void GetCbuf16(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, const | |||
| 98 | GetCbuf(ctx, ret, binding, offset, 16, cast, bit_offset); | 98 | GetCbuf(ctx, ret, binding, offset, 16, cast, bit_offset); |
| 99 | } | 99 | } |
| 100 | } | 100 | } |
| 101 | |||
| 102 | u32 TexCoordIndex(IR::Attribute attr) { | ||
| 103 | return (static_cast<u32>(attr) - static_cast<u32>(IR::Attribute::FixedFncTexture0S)) / 4; | ||
| 104 | } | ||
| 105 | } // Anonymous namespace | 101 | } // Anonymous namespace |
| 106 | 102 | ||
| 107 | void EmitGetCbufU8(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, | 103 | void EmitGetCbufU8(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, |
| @@ -190,18 +186,6 @@ void EmitGetAttribute(EmitContext& ctx, IR::Inst& inst, IR::Attribute attr, | |||
| 190 | ctx.AddF32("{}=in_attr{}{}.{};", inst, index, InputVertexIndex(ctx, vertex), swizzle); | 186 | ctx.AddF32("{}=in_attr{}{}.{};", inst, index, InputVertexIndex(ctx, vertex), swizzle); |
| 191 | return; | 187 | return; |
| 192 | } | 188 | } |
| 193 | // GLSL only exposes 8 legacy texcoords | ||
| 194 | if (attr >= IR::Attribute::FixedFncTexture8S && attr <= IR::Attribute::FixedFncTexture9Q) { | ||
| 195 | LOG_WARNING(Shader_GLSL, "GLSL does not allow access to gl_TexCoord[{}]", | ||
| 196 | TexCoordIndex(attr)); | ||
| 197 | ctx.AddF32("{}=0.f;", inst); | ||
| 198 | return; | ||
| 199 | } | ||
| 200 | if (attr >= IR::Attribute::FixedFncTexture0S && attr <= IR::Attribute::FixedFncTexture7Q) { | ||
| 201 | const u32 index{TexCoordIndex(attr)}; | ||
| 202 | ctx.AddF32("{}=gl_TexCoord[{}].{};", inst, index, swizzle); | ||
| 203 | return; | ||
| 204 | } | ||
| 205 | switch (attr) { | 189 | switch (attr) { |
| 206 | case IR::Attribute::PrimitiveId: | 190 | case IR::Attribute::PrimitiveId: |
| 207 | ctx.AddF32("{}=itof(gl_PrimitiveID);", inst); | 191 | ctx.AddF32("{}=itof(gl_PrimitiveID);", inst); |
| @@ -215,16 +199,6 @@ void EmitGetAttribute(EmitContext& ctx, IR::Inst& inst, IR::Attribute attr, | |||
| 215 | ctx.AddF32("{}={}{}.{};", inst, input_decorator, ctx.position_name, swizzle); | 199 | ctx.AddF32("{}={}{}.{};", inst, input_decorator, ctx.position_name, swizzle); |
| 216 | break; | 200 | break; |
| 217 | } | 201 | } |
| 218 | case IR::Attribute::ColorFrontDiffuseR: | ||
| 219 | case IR::Attribute::ColorFrontDiffuseG: | ||
| 220 | case IR::Attribute::ColorFrontDiffuseB: | ||
| 221 | case IR::Attribute::ColorFrontDiffuseA: | ||
| 222 | if (ctx.stage == Stage::Fragment) { | ||
| 223 | ctx.AddF32("{}=gl_Color.{};", inst, swizzle); | ||
| 224 | } else { | ||
| 225 | ctx.AddF32("{}=gl_FrontColor.{};", inst, swizzle); | ||
| 226 | } | ||
| 227 | break; | ||
| 228 | case IR::Attribute::PointSpriteS: | 202 | case IR::Attribute::PointSpriteS: |
| 229 | case IR::Attribute::PointSpriteT: | 203 | case IR::Attribute::PointSpriteT: |
| 230 | ctx.AddF32("{}=gl_PointCoord.{};", inst, swizzle); | 204 | ctx.AddF32("{}=gl_PointCoord.{};", inst, swizzle); |
| @@ -264,17 +238,6 @@ void EmitSetAttribute(EmitContext& ctx, IR::Attribute attr, std::string_view val | |||
| 264 | } | 238 | } |
| 265 | const u32 element{static_cast<u32>(attr) % 4}; | 239 | const u32 element{static_cast<u32>(attr) % 4}; |
| 266 | const char swizzle{"xyzw"[element]}; | 240 | const char swizzle{"xyzw"[element]}; |
| 267 | // GLSL only exposes 8 legacy texcoords | ||
| 268 | if (attr >= IR::Attribute::FixedFncTexture8S && attr <= IR::Attribute::FixedFncTexture9Q) { | ||
| 269 | LOG_WARNING(Shader_GLSL, "GLSL does not allow access to gl_TexCoord[{}]", | ||
| 270 | TexCoordIndex(attr)); | ||
| 271 | return; | ||
| 272 | } | ||
| 273 | if (attr >= IR::Attribute::FixedFncTexture0S && attr <= IR::Attribute::FixedFncTexture7Q) { | ||
| 274 | const u32 index{TexCoordIndex(attr)}; | ||
| 275 | ctx.Add("gl_TexCoord[{}].{}={};", index, swizzle, value); | ||
| 276 | return; | ||
| 277 | } | ||
| 278 | switch (attr) { | 241 | switch (attr) { |
| 279 | case IR::Attribute::Layer: | 242 | case IR::Attribute::Layer: |
| 280 | if (ctx.stage != Stage::Geometry && | 243 | if (ctx.stage != Stage::Geometry && |
| @@ -312,33 +275,6 @@ void EmitSetAttribute(EmitContext& ctx, IR::Attribute attr, std::string_view val | |||
| 312 | case IR::Attribute::PositionW: | 275 | case IR::Attribute::PositionW: |
| 313 | ctx.Add("gl_Position.{}={};", swizzle, value); | 276 | ctx.Add("gl_Position.{}={};", swizzle, value); |
| 314 | break; | 277 | break; |
| 315 | case IR::Attribute::ColorFrontDiffuseR: | ||
| 316 | case IR::Attribute::ColorFrontDiffuseG: | ||
| 317 | case IR::Attribute::ColorFrontDiffuseB: | ||
| 318 | case IR::Attribute::ColorFrontDiffuseA: | ||
| 319 | ctx.Add("gl_FrontColor.{}={};", swizzle, value); | ||
| 320 | break; | ||
| 321 | case IR::Attribute::ColorFrontSpecularR: | ||
| 322 | case IR::Attribute::ColorFrontSpecularG: | ||
| 323 | case IR::Attribute::ColorFrontSpecularB: | ||
| 324 | case IR::Attribute::ColorFrontSpecularA: | ||
| 325 | ctx.Add("gl_FrontSecondaryColor.{}={};", swizzle, value); | ||
| 326 | break; | ||
| 327 | case IR::Attribute::ColorBackDiffuseR: | ||
| 328 | case IR::Attribute::ColorBackDiffuseG: | ||
| 329 | case IR::Attribute::ColorBackDiffuseB: | ||
| 330 | case IR::Attribute::ColorBackDiffuseA: | ||
| 331 | ctx.Add("gl_BackColor.{}={};", swizzle, value); | ||
| 332 | break; | ||
| 333 | case IR::Attribute::ColorBackSpecularR: | ||
| 334 | case IR::Attribute::ColorBackSpecularG: | ||
| 335 | case IR::Attribute::ColorBackSpecularB: | ||
| 336 | case IR::Attribute::ColorBackSpecularA: | ||
| 337 | ctx.Add("gl_BackSecondaryColor.{}={};", swizzle, value); | ||
| 338 | break; | ||
| 339 | case IR::Attribute::FogCoordinate: | ||
| 340 | ctx.Add("gl_FogFragCoord={};", value); | ||
| 341 | break; | ||
| 342 | case IR::Attribute::ClipDistance0: | 278 | case IR::Attribute::ClipDistance0: |
| 343 | case IR::Attribute::ClipDistance1: | 279 | case IR::Attribute::ClipDistance1: |
| 344 | case IR::Attribute::ClipDistance2: | 280 | case IR::Attribute::ClipDistance2: |
diff --git a/src/shader_recompiler/backend/glsl/glsl_emit_context.cpp b/src/shader_recompiler/backend/glsl/glsl_emit_context.cpp index 1de017e76..bc9d2a904 100644 --- a/src/shader_recompiler/backend/glsl/glsl_emit_context.cpp +++ b/src/shader_recompiler/backend/glsl/glsl_emit_context.cpp | |||
| @@ -211,27 +211,6 @@ std::string_view OutputPrimitive(OutputTopology topology) { | |||
| 211 | throw InvalidArgument("Invalid output topology {}", topology); | 211 | throw InvalidArgument("Invalid output topology {}", topology); |
| 212 | } | 212 | } |
| 213 | 213 | ||
| 214 | void SetupLegacyOutPerVertex(EmitContext& ctx, std::string& header) { | ||
| 215 | if (!ctx.info.stores.Legacy()) { | ||
| 216 | return; | ||
| 217 | } | ||
| 218 | if (ctx.info.stores.FixedFunctionTexture()) { | ||
| 219 | header += "vec4 gl_TexCoord[8];"; | ||
| 220 | } | ||
| 221 | if (ctx.info.stores.AnyComponent(IR::Attribute::ColorFrontDiffuseR)) { | ||
| 222 | header += "vec4 gl_FrontColor;"; | ||
| 223 | } | ||
| 224 | if (ctx.info.stores.AnyComponent(IR::Attribute::ColorFrontSpecularR)) { | ||
| 225 | header += "vec4 gl_FrontSecondaryColor;"; | ||
| 226 | } | ||
| 227 | if (ctx.info.stores.AnyComponent(IR::Attribute::ColorBackDiffuseR)) { | ||
| 228 | header += "vec4 gl_BackColor;"; | ||
| 229 | } | ||
| 230 | if (ctx.info.stores.AnyComponent(IR::Attribute::ColorBackSpecularR)) { | ||
| 231 | header += "vec4 gl_BackSecondaryColor;"; | ||
| 232 | } | ||
| 233 | } | ||
| 234 | |||
| 235 | void SetupOutPerVertex(EmitContext& ctx, std::string& header) { | 214 | void SetupOutPerVertex(EmitContext& ctx, std::string& header) { |
| 236 | if (!StoresPerVertexAttributes(ctx.stage)) { | 215 | if (!StoresPerVertexAttributes(ctx.stage)) { |
| 237 | return; | 216 | return; |
| @@ -250,7 +229,6 @@ void SetupOutPerVertex(EmitContext& ctx, std::string& header) { | |||
| 250 | ctx.profile.support_viewport_index_layer_non_geometry && ctx.stage != Stage::Geometry) { | 229 | ctx.profile.support_viewport_index_layer_non_geometry && ctx.stage != Stage::Geometry) { |
| 251 | header += "int gl_ViewportIndex;"; | 230 | header += "int gl_ViewportIndex;"; |
| 252 | } | 231 | } |
| 253 | SetupLegacyOutPerVertex(ctx, header); | ||
| 254 | header += "};"; | 232 | header += "};"; |
| 255 | if (ctx.info.stores[IR::Attribute::ViewportIndex] && ctx.stage == Stage::Geometry) { | 233 | if (ctx.info.stores[IR::Attribute::ViewportIndex] && ctx.stage == Stage::Geometry) { |
| 256 | header += "out int gl_ViewportIndex;"; | 234 | header += "out int gl_ViewportIndex;"; |
| @@ -282,21 +260,6 @@ void SetupInPerVertex(EmitContext& ctx, std::string& header) { | |||
| 282 | } | 260 | } |
| 283 | header += "}gl_in[gl_MaxPatchVertices];"; | 261 | header += "}gl_in[gl_MaxPatchVertices];"; |
| 284 | } | 262 | } |
| 285 | |||
| 286 | void SetupLegacyInPerFragment(EmitContext& ctx, std::string& header) { | ||
| 287 | if (!ctx.info.loads.Legacy()) { | ||
| 288 | return; | ||
| 289 | } | ||
| 290 | header += "in gl_PerFragment{"; | ||
| 291 | if (ctx.info.loads.FixedFunctionTexture()) { | ||
| 292 | header += "vec4 gl_TexCoord[8];"; | ||
| 293 | } | ||
| 294 | if (ctx.info.loads.AnyComponent(IR::Attribute::ColorFrontDiffuseR)) { | ||
| 295 | header += "vec4 gl_Color;"; | ||
| 296 | } | ||
| 297 | header += "};"; | ||
| 298 | } | ||
| 299 | |||
| 300 | } // Anonymous namespace | 263 | } // Anonymous namespace |
| 301 | 264 | ||
| 302 | EmitContext::EmitContext(IR::Program& program, Bindings& bindings, const Profile& profile_, | 265 | EmitContext::EmitContext(IR::Program& program, Bindings& bindings, const Profile& profile_, |
| @@ -361,7 +324,6 @@ EmitContext::EmitContext(IR::Program& program, Bindings& bindings, const Profile | |||
| 361 | } | 324 | } |
| 362 | SetupOutPerVertex(*this, header); | 325 | SetupOutPerVertex(*this, header); |
| 363 | SetupInPerVertex(*this, header); | 326 | SetupInPerVertex(*this, header); |
| 364 | SetupLegacyInPerFragment(*this, header); | ||
| 365 | 327 | ||
| 366 | for (size_t index = 0; index < IR::NUM_GENERICS; ++index) { | 328 | for (size_t index = 0; index < IR::NUM_GENERICS; ++index) { |
| 367 | if (!info.loads.Generic(index) || !runtime_info.previous_stage_stores.Generic(index)) { | 329 | if (!info.loads.Generic(index) || !runtime_info.previous_stage_stores.Generic(index)) { |