diff options
author | ameerj <52414509+ameerj@users.noreply.github.com> | 2021-05-26 06:16:20 +0200 |
---|---|---|
committer | ameerj <52414509+ameerj@users.noreply.github.com> | 2021-07-23 03:51:36 +0200 |
commit | 3d086e6130a2c5f0546ccef3b234c65ef2f0c99b (patch) | |
tree | eaddf938c32f9a077ff671db4e9ebe9634304033 /src/shader_recompiler/backend/glsl/emit_glsl_context_get_set.cpp | |
parent | glsl: Track S32 atomics (diff) | |
download | yuzu-3d086e6130a2c5f0546ccef3b234c65ef2f0c99b.tar yuzu-3d086e6130a2c5f0546ccef3b234c65ef2f0c99b.tar.gz yuzu-3d086e6130a2c5f0546ccef3b234c65ef2f0c99b.tar.bz2 yuzu-3d086e6130a2c5f0546ccef3b234c65ef2f0c99b.tar.lz yuzu-3d086e6130a2c5f0546ccef3b234c65ef2f0c99b.tar.xz yuzu-3d086e6130a2c5f0546ccef3b234c65ef2f0c99b.tar.zst yuzu-3d086e6130a2c5f0546ccef3b234c65ef2f0c99b.zip |
Diffstat (limited to 'src/shader_recompiler/backend/glsl/emit_glsl_context_get_set.cpp')
-rw-r--r-- | src/shader_recompiler/backend/glsl/emit_glsl_context_get_set.cpp | 53 |
1 files changed, 53 insertions, 0 deletions
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 7c9cadd7e..441818c0b 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 @@ -51,4 +51,57 @@ void EmitGetCbufU32x2([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] const [[maybe_unused]] const IR::Value& offset) { throw NotImplementedException("GLSL"); } + +void EmitGetAttribute(EmitContext& ctx, IR::Inst& inst, IR::Attribute attr, + [[maybe_unused]] std::string_view vertex) { + const u32 element{static_cast<u32>(attr) % 4}; + const char swizzle{"xyzw"[element]}; + if (IR::IsGeneric(attr)) { + const u32 index{IR::GenericAttributeIndex(attr)}; + ctx.AddF32("{}=in_attr{}.{};", inst, index, swizzle); + return; + } + switch (attr) { + case IR::Attribute::PositionX: + case IR::Attribute::PositionY: + case IR::Attribute::PositionZ: + case IR::Attribute::PositionW: + ctx.AddF32("{}=gl_Position.{};", inst, swizzle); + break; + default: + fmt::print("Get attribute {}", attr); + throw NotImplementedException("Get attribute {}", attr); + } +} + +void EmitSetAttribute(EmitContext& ctx, IR::Attribute attr, std::string_view value, + [[maybe_unused]] std::string_view vertex) { + const u32 element{static_cast<u32>(attr) % 4}; + const char swizzle{"xyzw"[element]}; + if (IR::IsGeneric(attr)) { + const u32 index{IR::GenericAttributeIndex(attr)}; + ctx.Add("out_attr{}.{}={};", index, swizzle, value); + return; + } + switch (attr) { + case IR::Attribute::PointSize: + ctx.Add("gl_Pointsize={};", value); + break; + case IR::Attribute::PositionX: + case IR::Attribute::PositionY: + case IR::Attribute::PositionZ: + case IR::Attribute::PositionW: + ctx.Add("gl_Position.{}={};", swizzle, value); + break; + default: + fmt::print("Set attribute {}", attr); + throw NotImplementedException("Set attribute {}", attr); + } +} + +void EmitSetFragColor(EmitContext& ctx, u32 index, u32 component, std::string_view value) { + const char swizzle{"xyzw"[component]}; + ctx.Add("frag_color{}.{}={};", index, swizzle, value); +} + } // namespace Shader::Backend::GLSL |