[Mesa-dev] [PATCH 06/59] glsl: Add a C++ code generator that uses ir_builder to rebuild a program
Ian Romanick
idr at freedesktop.org
Fri Oct 28 02:50:58 UTC 2016
On 10/27/2016 05:40 AM, Nicolai Hähnle wrote:
> On 26.10.2016 02:59, Ian Romanick wrote:
>> From: Ian Romanick <ian.d.romanick at intel.com>
>>
>> This is only in libstandalone currently because it will only be used in
>> the stand-alone compiler.
>>
>> v2: Change the signature of the generated function. The ir_factory is
>> created in the generator, and an availability predicate is taken as a
>> parameter.
>>
>> Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
>> ---
>> src/compiler/Makefile.sources | 2 +
>> src/compiler/glsl/ir_builder_print_visitor.cpp | 756
>> +++++++++++++++++++++++++
>> src/compiler/glsl/ir_builder_print_visitor.h | 32 ++
>> 3 files changed, 790 insertions(+)
>> create mode 100644 src/compiler/glsl/ir_builder_print_visitor.cpp
>> create mode 100644 src/compiler/glsl/ir_builder_print_visitor.h
>>
>> diff --git a/src/compiler/Makefile.sources
>> b/src/compiler/Makefile.sources
>> index a30443d..9f2d362 100644
>> --- a/src/compiler/Makefile.sources
>> +++ b/src/compiler/Makefile.sources
>> @@ -142,6 +142,8 @@ LIBGLSL_SHADER_CACHE_FILES = \
>> # glsl_compiler
>>
>> GLSL_COMPILER_CXX_FILES = \
>> + glsl/ir_builder_print_visitor.cpp \
>> + glsl/ir_builder_print_visitor.h \
>> glsl/standalone_scaffolding.cpp \
>> glsl/standalone_scaffolding.h \
>> glsl/standalone.cpp \
>> diff --git a/src/compiler/glsl/ir_builder_print_visitor.cpp
>> b/src/compiler/glsl/ir_builder_print_visitor.cpp
>> new file mode 100644
>> index 0000000..d7bba9b
>> --- /dev/null
>> +++ b/src/compiler/glsl/ir_builder_print_visitor.cpp
> [snip]
>> +ir_visitor_status
>> +ir_builder_print_visitor::visit(ir_variable *ir)
>> +{
>> + const unsigned my_index = next_ir_index++;
>> +
>> + _mesa_hash_table_insert(index_map, ir, (void *)(uintptr_t) my_index);
>> +
>> + const char *mode_str;
>> + switch (ir->data.mode) {
>> + case ir_var_auto: mode_str = "ir_var_auto"; break;
>> + case ir_var_uniform: mode_str = "ir_var_uniform"; break;
>> + case ir_var_shader_storage: mode_str = "ir_var_shader_storage";
>> break;
>> + case ir_var_shader_shared: mode_str = "ir_var_shader_shared"; break;
>> + case ir_var_shader_in: mode_str = "ir_var_shader_in"; break;
>> + case ir_var_shader_out: mode_str = "ir_var_shader_out"; break;
>> + case ir_var_function_in: mode_str = "ir_var_function_in"; break;
>> + case ir_var_function_out: mode_str = "ir_var_function_out"; break;
>> + case ir_var_function_inout: mode_str = "ir_var_function_inout";
>> break;
>> + case ir_var_const_in: mode_str = "ir_var_const_in"; break;
>> + case ir_var_system_value: mode_str = "ir_var_system_value"; break;
>> + case ir_var_temporary: mode_str = "ir_var_temporary"; break;
>> + default:
>> + unreachable("Invalid variable mode");
>> + }
>> +
>> + if (ir->data.mode == ir_var_temporary) {
>> + print_with_indent("ir_variable *const r%04X =
>> body.make_temp(glsl_type::%s_type, \"%s\");\n",
>> + my_index,
>> + ir->type->name,
>
> I take it this is not meant to be used for code with more complex types?
Guilty. :) I basically implemented the things that I needed.
> Apart from that, this pair of patches looks reasonable; 5 & 6:
>
> Reviewed-by: Nicolai Hähnle <nicolai.haehnle at amd.com>
>
More information about the mesa-dev
mailing list