From ed14d31f663e126a8f9fe0ea8abff8e27c46248b Mon Sep 17 00:00:00 2001
From: ameerj <52414509+ameerj@users.noreply.github.com>
Date: Thu, 27 May 2021 00:26:16 -0400
Subject: glsl: Fix non-immediate buffer access

and many other misc implementations
---
 .../backend/glsl/emit_glsl_composite.cpp           | 48 ++++++++--------------
 1 file changed, 18 insertions(+), 30 deletions(-)

(limited to 'src/shader_recompiler/backend/glsl/emit_glsl_composite.cpp')

diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_composite.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_composite.cpp
index 048b12f38f..aa966a304f 100644
--- a/src/shader_recompiler/backend/glsl/emit_glsl_composite.cpp
+++ b/src/shader_recompiler/backend/glsl/emit_glsl_composite.cpp
@@ -17,19 +17,14 @@ void EmitCompositeConstructU32x2(EmitContext& ctx, IR::Inst& inst, std::string_v
     ctx.AddU32x2("{}=uvec2({},{});", inst, e1, e2);
 }
 
-void EmitCompositeConstructU32x3([[maybe_unused]] EmitContext& ctx,
-                                 [[maybe_unused]] std::string_view e1,
-                                 [[maybe_unused]] std::string_view e2,
-                                 [[maybe_unused]] std::string_view e3) {
-    throw NotImplementedException("GLSL Instruction");
+void EmitCompositeConstructU32x3(EmitContext& ctx, IR::Inst& inst, std::string_view e1,
+                                 std::string_view e2, std::string_view e3) {
+    ctx.AddU32x3("{}=uvec3({},{},{});", inst, e1, e2, e3);
 }
 
-void EmitCompositeConstructU32x4([[maybe_unused]] EmitContext& ctx,
-                                 [[maybe_unused]] std::string_view e1,
-                                 [[maybe_unused]] std::string_view e2,
-                                 [[maybe_unused]] std::string_view e3,
-                                 [[maybe_unused]] std::string_view e4) {
-    throw NotImplementedException("GLSL Instruction");
+void EmitCompositeConstructU32x4(EmitContext& ctx, IR::Inst& inst, std::string_view e1,
+                                 std::string_view e2, std::string_view e3, std::string_view e4) {
+    ctx.AddU32x4("{}=uvec4({},{},{},{});", inst, e1, e2, e3, e4);
 }
 
 void EmitCompositeExtractU32x2(EmitContext& ctx, IR::Inst& inst, std::string_view composite,
@@ -37,16 +32,14 @@ void EmitCompositeExtractU32x2(EmitContext& ctx, IR::Inst& inst, std::string_vie
     ctx.AddU32("{}={}.{};", inst, composite, SWIZZLE[index]);
 }
 
-void EmitCompositeExtractU32x3([[maybe_unused]] EmitContext& ctx,
-                               [[maybe_unused]] std::string_view composite,
-                               [[maybe_unused]] u32 index) {
-    throw NotImplementedException("GLSL Instruction");
+void EmitCompositeExtractU32x3(EmitContext& ctx, IR::Inst& inst, std::string_view composite,
+                               u32 index) {
+    ctx.AddU32("{}={}.{};", inst, composite, SWIZZLE[index]);
 }
 
-void EmitCompositeExtractU32x4([[maybe_unused]] EmitContext& ctx,
-                               [[maybe_unused]] std::string_view composite,
-                               [[maybe_unused]] u32 index) {
-    throw NotImplementedException("GLSL Instruction");
+void EmitCompositeExtractU32x4(EmitContext& ctx, IR::Inst& inst, std::string_view composite,
+                               u32 index) {
+    ctx.AddU32("{}={}.{};", inst, composite, SWIZZLE[index]);
 }
 
 void EmitCompositeInsertU32x2([[maybe_unused]] EmitContext& ctx,
@@ -135,19 +128,14 @@ void EmitCompositeConstructF32x2(EmitContext& ctx, IR::Inst& inst, std::string_v
     ctx.AddF32x2("{}=vec2({},{});", inst, e1, e2);
 }
 
-void EmitCompositeConstructF32x3([[maybe_unused]] EmitContext& ctx,
-                                 [[maybe_unused]] std::string_view e1,
-                                 [[maybe_unused]] std::string_view e2,
-                                 [[maybe_unused]] std::string_view e3) {
-    throw NotImplementedException("GLSL Instruction");
+void EmitCompositeConstructF32x3(EmitContext& ctx, IR::Inst& inst, std::string_view e1,
+                                 std::string_view e2, std::string_view e3) {
+    ctx.AddF32x3("{}=vec3({},{},{});", inst, e1, e2, e3);
 }
 
-void EmitCompositeConstructF32x4([[maybe_unused]] EmitContext& ctx,
-                                 [[maybe_unused]] std::string_view e1,
-                                 [[maybe_unused]] std::string_view e2,
-                                 [[maybe_unused]] std::string_view e3,
-                                 [[maybe_unused]] std::string_view e4) {
-    throw NotImplementedException("GLSL Instruction");
+void EmitCompositeConstructF32x4(EmitContext& ctx, IR::Inst& inst, std::string_view e1,
+                                 std::string_view e2, std::string_view e3, std::string_view e4) {
+    ctx.AddF32x4("{}=vec4({},{},{},{});", inst, e1, e2, e3, e4);
 }
 
 void EmitCompositeExtractF32x2(EmitContext& ctx, IR::Inst& inst, std::string_view composite,
-- 
cgit v1.2.3-70-g09d2