summaryrefslogtreecommitdiff
path: root/src/shader_recompiler/backend/glasm/emit_glasm.cpp
diff options
context:
space:
mode:
authorGravatar ReinUsesLisp2021-05-19 16:32:03 -0300
committerGravatar ameerj2021-07-22 21:51:32 -0400
commitaccad56ee7cc9f77886d164701a35f1e89a3519b (patch)
tree34b272f1f70d0c4d926877c4e960ccec0084ce17 /src/shader_recompiler/backend/glasm/emit_glasm.cpp
parentglasm: Implement gl_PointSize stores (diff)
downloadyuzu-accad56ee7cc9f77886d164701a35f1e89a3519b.tar.gz
yuzu-accad56ee7cc9f77886d164701a35f1e89a3519b.tar.xz
yuzu-accad56ee7cc9f77886d164701a35f1e89a3519b.zip
glasm: Implement stores to gl_ViewportIndex
Diffstat (limited to 'src/shader_recompiler/backend/glasm/emit_glasm.cpp')
-rw-r--r--src/shader_recompiler/backend/glasm/emit_glasm.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/shader_recompiler/backend/glasm/emit_glasm.cpp b/src/shader_recompiler/backend/glasm/emit_glasm.cpp
index edf6f5e13..9dc0cacbe 100644
--- a/src/shader_recompiler/backend/glasm/emit_glasm.cpp
+++ b/src/shader_recompiler/backend/glasm/emit_glasm.cpp
@@ -261,7 +261,10 @@ void EmitCode(EmitContext& ctx, const IR::Program& program) {
261 } 261 }
262} 262}
263 263
264void SetupOptions(std::string& header, Info info) { 264void SetupOptions(const IR::Program& program, const Profile& profile, std::string& header) {
265 const Info& info{program.info};
266 const Stage stage{program.stage};
267
265 // TODO: Track the shared atomic ops 268 // TODO: Track the shared atomic ops
266 header += "OPTION NV_internal;" 269 header += "OPTION NV_internal;"
267 "OPTION NV_shader_storage_buffer;" 270 "OPTION NV_shader_storage_buffer;"
@@ -286,6 +289,11 @@ void SetupOptions(std::string& header, Info info) {
286 if (info.uses_sparse_residency) { 289 if (info.uses_sparse_residency) {
287 header += "OPTION EXT_sparse_texture2;"; 290 header += "OPTION EXT_sparse_texture2;";
288 } 291 }
292 if ((info.stores_viewport_index || info.stores_layer) && stage != Stage::Geometry) {
293 if (profile.support_viewport_index_layer_non_geometry) {
294 header += "OPTION NV_viewport_array2;";
295 }
296 }
289 const auto non_zero_frag_colors{info.stores_frag_color | std::views::drop(1)}; 297 const auto non_zero_frag_colors{info.stores_frag_color | std::views::drop(1)};
290 if (std::ranges::find(non_zero_frag_colors, true) != non_zero_frag_colors.end()) { 298 if (std::ranges::find(non_zero_frag_colors, true) != non_zero_frag_colors.end()) {
291 header += "OPTION ARB_draw_buffers;"; 299 header += "OPTION ARB_draw_buffers;";
@@ -312,12 +320,12 @@ std::string_view StageHeader(Stage stage) {
312} 320}
313} // Anonymous namespace 321} // Anonymous namespace
314 322
315std::string EmitGLASM(const Profile&, IR::Program& program, Bindings& bindings) { 323std::string EmitGLASM(const Profile& profile, IR::Program& program, Bindings& bindings) {
316 EmitContext ctx{program, bindings}; 324 EmitContext ctx{program, bindings, profile};
317 Precolor(ctx, program); 325 Precolor(ctx, program);
318 EmitCode(ctx, program); 326 EmitCode(ctx, program);
319 std::string header{StageHeader(program.stage)}; 327 std::string header{StageHeader(program.stage)};
320 SetupOptions(header, program.info); 328 SetupOptions(program, profile, header);
321 switch (program.stage) { 329 switch (program.stage) {
322 case Stage::Compute: 330 case Stage::Compute:
323 header += fmt::format("GROUP_SIZE {} {} {};", program.workgroup_size[0], 331 header += fmt::format("GROUP_SIZE {} {} {};", program.workgroup_size[0],