From 1d6b4794a9b6ddb83749352bb86b5296e6cebc72 Mon Sep 17 00:00:00 2001 From: Don Williamson Date: Wed, 1 Mar 2017 17:01:54 +0000 Subject: [PATCH] Support for high precision Metal texture samplers. (#1060) * GL Renderer, OSX, no swap chain: Bind back buffer fbo ready for NSOpenGLContext flushBuffer * Support for high precision Metal texture samplers. --- .../glsl-optimizer/src/glsl/glsl_optimizer.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/3rdparty/glsl-optimizer/src/glsl/glsl_optimizer.cpp b/3rdparty/glsl-optimizer/src/glsl/glsl_optimizer.cpp index 5e0b21b96..5d790f7fd 100644 --- a/3rdparty/glsl-optimizer/src/glsl/glsl_optimizer.cpp +++ b/3rdparty/glsl-optimizer/src/glsl/glsl_optimizer.cpp @@ -280,6 +280,14 @@ static void propagate_precision_texture(ir_instruction *ir, void *data) ((precision_ctx*)data)->res = true; } +static void propagate_precision_texture_metal(ir_instruction* ir, void* data) +{ + // There are no precision specifiers in Metal + ir_texture* tex = ir->as_texture(); + if (tex) + tex->set_precision(glsl_precision_undefined); +} + struct undefined_ass_ctx { ir_variable* var; @@ -386,7 +394,7 @@ static void propagate_precision_call(ir_instruction *ir, void *data) } } -static bool propagate_precision(exec_list* list, bool assign_high_to_undefined) +static bool propagate_precision(exec_list* list, bool metal_target) { bool anyProgress = false; precision_ctx ctx; @@ -396,7 +404,11 @@ static bool propagate_precision(exec_list* list, bool assign_high_to_undefined) ctx.root_ir = list; foreach_in_list(ir_instruction, ir, list) { - visit_tree (ir, propagate_precision_texture, &ctx); + if (metal_target) + visit_tree (ir, propagate_precision_texture_metal, &ctx); + else + visit_tree (ir, propagate_precision_texture, &ctx); + visit_tree (ir, propagate_precision_deref, &ctx); bool hadProgress = ctx.res; ctx.res = false; @@ -417,7 +429,7 @@ static bool propagate_precision(exec_list* list, bool assign_high_to_undefined) anyProgress |= ctx.res; // for globals that have undefined precision, set it to highp - if (assign_high_to_undefined) + if (metal_target) { foreach_in_list(ir_instruction, ir, list) {