diff options
| author | 2021-10-26 23:01:57 +0800 | |
|---|---|---|
| committer | 2021-10-26 23:01:57 +0800 | |
| commit | b04c7b63435ad51ce747d678be3fe5899f14609e (patch) | |
| tree | fbebe3acce60013e5ca9e9a7c6155c28ab51fdd9 /src/shader_recompiler/backend | |
| parent | Merge pull request #7218 from bylaws/aswdqdsam (diff) | |
| download | yuzu-b04c7b63435ad51ce747d678be3fe5899f14609e.tar.gz yuzu-b04c7b63435ad51ce747d678be3fe5899f14609e.tar.xz yuzu-b04c7b63435ad51ce747d678be3fe5899f14609e.zip | |
Support gl_BackColor attribute
Diffstat (limited to 'src/shader_recompiler/backend')
3 files changed, 33 insertions, 0 deletions
diff --git a/src/shader_recompiler/backend/spirv/emit_context.cpp b/src/shader_recompiler/backend/spirv/emit_context.cpp index 2885e6799..9d84c4fc6 100644 --- a/src/shader_recompiler/backend/spirv/emit_context.cpp +++ b/src/shader_recompiler/backend/spirv/emit_context.cpp | |||
| @@ -1286,6 +1286,14 @@ void EmitContext::DefineInputs(const IR::Program& program) { | |||
| 1286 | Decorate(id, spv::Decoration::Location, location); | 1286 | Decorate(id, spv::Decoration::Location, location); |
| 1287 | input_front_color = id; | 1287 | input_front_color = id; |
| 1288 | } | 1288 | } |
| 1289 | if (loads.AnyComponent(IR::Attribute::ColorBackDiffuseR)) { | ||
| 1290 | const size_t location = FindNextUnusedLocation(used_locations, previous_unused_location); | ||
| 1291 | previous_unused_location = location; | ||
| 1292 | used_locations.set(location); | ||
| 1293 | const Id id{DefineInput(*this, F32[4], true)}; | ||
| 1294 | Decorate(id, spv::Decoration::Location, location); | ||
| 1295 | input_back_color = id; | ||
| 1296 | } | ||
| 1289 | for (size_t index = 0; index < NUM_FIXEDFNCTEXTURE; ++index) { | 1297 | for (size_t index = 0; index < NUM_FIXEDFNCTEXTURE; ++index) { |
| 1290 | if (loads.AnyComponent(IR::Attribute::FixedFncTexture0S + index * 4)) { | 1298 | if (loads.AnyComponent(IR::Attribute::FixedFncTexture0S + index * 4)) { |
| 1291 | const size_t location = | 1299 | const size_t location = |
| @@ -1363,6 +1371,14 @@ void EmitContext::DefineOutputs(const IR::Program& program) { | |||
| 1363 | Decorate(id, spv::Decoration::Location, static_cast<u32>(location)); | 1371 | Decorate(id, spv::Decoration::Location, static_cast<u32>(location)); |
| 1364 | output_front_color = id; | 1372 | output_front_color = id; |
| 1365 | } | 1373 | } |
| 1374 | if (info.stores.AnyComponent(IR::Attribute::ColorBackDiffuseR)) { | ||
| 1375 | const size_t location = FindNextUnusedLocation(used_locations, previous_unused_location); | ||
| 1376 | previous_unused_location = location; | ||
| 1377 | used_locations.set(location); | ||
| 1378 | const Id id{DefineOutput(*this, F32[4], invocations)}; | ||
| 1379 | Decorate(id, spv::Decoration::Location, static_cast<u32>(location)); | ||
| 1380 | output_back_color = id; | ||
| 1381 | } | ||
| 1366 | for (size_t index = 0; index < NUM_FIXEDFNCTEXTURE; ++index) { | 1382 | for (size_t index = 0; index < NUM_FIXEDFNCTEXTURE; ++index) { |
| 1367 | if (info.stores.AnyComponent(IR::Attribute::FixedFncTexture0S + index * 4)) { | 1383 | if (info.stores.AnyComponent(IR::Attribute::FixedFncTexture0S + index * 4)) { |
| 1368 | const size_t location = | 1384 | const size_t location = |
diff --git a/src/shader_recompiler/backend/spirv/emit_context.h b/src/shader_recompiler/backend/spirv/emit_context.h index 847d0c0e6..d2bc0a952 100644 --- a/src/shader_recompiler/backend/spirv/emit_context.h +++ b/src/shader_recompiler/backend/spirv/emit_context.h | |||
| @@ -269,12 +269,14 @@ public: | |||
| 269 | 269 | ||
| 270 | Id input_position{}; | 270 | Id input_position{}; |
| 271 | Id input_front_color{}; | 271 | Id input_front_color{}; |
| 272 | Id input_back_color{}; | ||
| 272 | std::array<Id, 10> input_fixed_fnc_textures{}; | 273 | std::array<Id, 10> input_fixed_fnc_textures{}; |
| 273 | std::array<Id, 32> input_generics{}; | 274 | std::array<Id, 32> input_generics{}; |
| 274 | 275 | ||
| 275 | Id output_point_size{}; | 276 | Id output_point_size{}; |
| 276 | Id output_position{}; | 277 | Id output_position{}; |
| 277 | Id output_front_color{}; | 278 | Id output_front_color{}; |
| 279 | Id output_back_color{}; | ||
| 278 | std::array<Id, 10> output_fixed_fnc_textures{}; | 280 | std::array<Id, 10> output_fixed_fnc_textures{}; |
| 279 | std::array<std::array<GenericElementInfo, 4>, 32> output_generics{}; | 281 | std::array<std::array<GenericElementInfo, 4>, 32> output_generics{}; |
| 280 | 282 | ||
diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp b/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp index 6f60c6574..899df6294 100644 --- a/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp +++ b/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp | |||
| @@ -119,6 +119,14 @@ std::optional<OutAttr> OutputAttrPointer(EmitContext& ctx, IR::Attribute attr) { | |||
| 119 | const Id element_id{ctx.Const(element)}; | 119 | const Id element_id{ctx.Const(element)}; |
| 120 | return OutputAccessChain(ctx, ctx.output_f32, ctx.output_front_color, element_id); | 120 | return OutputAccessChain(ctx, ctx.output_f32, ctx.output_front_color, element_id); |
| 121 | } | 121 | } |
| 122 | case IR::Attribute::ColorBackDiffuseR: | ||
| 123 | case IR::Attribute::ColorBackDiffuseG: | ||
| 124 | case IR::Attribute::ColorBackDiffuseB: | ||
| 125 | case IR::Attribute::ColorBackDiffuseA: { | ||
| 126 | const u32 element{static_cast<u32>(attr) % 4}; | ||
| 127 | const Id element_id{ctx.Const(element)}; | ||
| 128 | return OutputAccessChain(ctx, ctx.output_f32, ctx.output_back_color, element_id); | ||
| 129 | } | ||
| 122 | case IR::Attribute::ClipDistance0: | 130 | case IR::Attribute::ClipDistance0: |
| 123 | case IR::Attribute::ClipDistance1: | 131 | case IR::Attribute::ClipDistance1: |
| 124 | case IR::Attribute::ClipDistance2: | 132 | case IR::Attribute::ClipDistance2: |
| @@ -363,6 +371,13 @@ Id EmitGetAttribute(EmitContext& ctx, IR::Attribute attr, Id vertex) { | |||
| 363 | return ctx.OpLoad(ctx.F32[1], AttrPointer(ctx, ctx.input_f32, vertex, ctx.input_front_color, | 371 | return ctx.OpLoad(ctx.F32[1], AttrPointer(ctx, ctx.input_f32, vertex, ctx.input_front_color, |
| 364 | ctx.Const(element))); | 372 | ctx.Const(element))); |
| 365 | } | 373 | } |
| 374 | case IR::Attribute::ColorBackDiffuseR: | ||
| 375 | case IR::Attribute::ColorBackDiffuseG: | ||
| 376 | case IR::Attribute::ColorBackDiffuseB: | ||
| 377 | case IR::Attribute::ColorBackDiffuseA: { | ||
| 378 | return ctx.OpLoad(ctx.F32[1], AttrPointer(ctx, ctx.input_f32, vertex, ctx.input_back_color, | ||
| 379 | ctx.Const(element))); | ||
| 380 | } | ||
| 366 | case IR::Attribute::InstanceId: | 381 | case IR::Attribute::InstanceId: |
| 367 | if (ctx.profile.support_vertex_instance_id) { | 382 | if (ctx.profile.support_vertex_instance_id) { |
| 368 | return ctx.OpBitcast(ctx.F32[1], ctx.OpLoad(ctx.U32[1], ctx.instance_id)); | 383 | return ctx.OpBitcast(ctx.F32[1], ctx.OpLoad(ctx.U32[1], ctx.instance_id)); |