Module: Mesa Branch: master Commit: 19e929a1774938cb826f68592dc87c520d048597 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=19e929a1774938cb826f68592dc87c520d048597
Author: Francisco Jerez <curroje...@riseup.net> Date: Tue Jul 19 20:10:21 2016 -0700 glsl: Handle the inout qualifier in fragment shader output declarations. According to the EXT_shader_framebuffer_fetch extension the inout qualifier can be used on ESSL 3.0+ shaders to declare a special kind of fragment output that gets implicitly initialized with the previous framebuffer contents at the current fragment coordinates. In addition we allow using the same language to define FB fetch outputs in GLSL 1.3+ shaders in preparation for the desktop MESA_shader_framebuffer_fetch extensions. Reviewed-by: Kenneth Graunke <kenn...@whitecape.org> --- src/compiler/glsl/ast_to_hir.cpp | 5 ++++- src/compiler/glsl/glsl_parser.yy | 12 ++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/compiler/glsl/ast_to_hir.cpp b/src/compiler/glsl/ast_to_hir.cpp index c05fb17..c91ed53 100644 --- a/src/compiler/glsl/ast_to_hir.cpp +++ b/src/compiler/glsl/ast_to_hir.cpp @@ -3713,7 +3713,7 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual, */ assert(var->data.mode != ir_var_temporary); if (qual->flags.q.in && qual->flags.q.out) - var->data.mode = ir_var_function_inout; + var->data.mode = is_parameter ? ir_var_function_inout : ir_var_shader_out; else if (qual->flags.q.in) var->data.mode = is_parameter ? ir_var_function_in : ir_var_shader_in; else if (qual->flags.q.attribute @@ -3730,6 +3730,9 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual, else if (qual->flags.q.shared_storage) var->data.mode = ir_var_shader_shared; + var->data.fb_fetch_output = state->stage == MESA_SHADER_FRAGMENT && + qual->flags.q.in && qual->flags.q.out; + if (!is_parameter && is_varying_var(var, state->stage)) { /* User-defined ins/outs are not permitted in compute shaders. */ if (state->stage == MESA_SHADER_COMPUTE) { diff --git a/src/compiler/glsl/glsl_parser.yy b/src/compiler/glsl/glsl_parser.yy index 5b65861..f2853da 100644 --- a/src/compiler/glsl/glsl_parser.yy +++ b/src/compiler/glsl/glsl_parser.yy @@ -1944,6 +1944,18 @@ storage_qualifier: $$.xfb_buffer = state->out_qualifier->xfb_buffer; } } + | INOUT_TOK + { + memset(& $$, 0, sizeof($$)); + $$.flags.q.in = 1; + $$.flags.q.out = 1; + + if (!state->has_framebuffer_fetch() || + !state->is_version(130, 300) || + state->stage != MESA_SHADER_FRAGMENT) + _mesa_glsl_error(&@1, state, "A single interface variable cannot be " + "declared as both input and output"); + } | UNIFORM { memset(& $$, 0, sizeof($$)); _______________________________________________ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit