head 1.1; branch 1.1.1; access; symbols netbsd-11-0-RC6:1.1.1.3 netbsd-11-0-RC5:1.1.1.3 netbsd-11-0-RC4:1.1.1.3 netbsd-11-0-RC3:1.1.1.3 netbsd-11-0-RC2:1.1.1.3 netbsd-11-0-RC1:1.1.1.3 netbsd-11:1.1.1.3.0.4 netbsd-11-base:1.1.1.3 netbsd-10-1-RELEASE:1.1.1.3 netbsd-9-4-RELEASE:1.1.1.1 netbsd-10-0-RELEASE:1.1.1.3 netbsd-10-0-RC6:1.1.1.3 netbsd-10-0-RC5:1.1.1.3 netbsd-10-0-RC4:1.1.1.3 netbsd-10-0-RC3:1.1.1.3 netbsd-10-0-RC2:1.1.1.3 netbsd-10-0-RC1:1.1.1.3 netbsd-10:1.1.1.3.0.2 netbsd-10-base:1.1.1.3 netbsd-9-3-RELEASE:1.1.1.1 mesa-21-3-7:1.1.1.3 netbsd-9-2-RELEASE:1.1.1.1 netbsd-9-1-RELEASE:1.1.1.1 netbsd-9-0-RELEASE:1.1.1.1 netbsd-9-0-RC2:1.1.1.1 netbsd-9-0-RC1:1.1.1.1 mesalib-19-1-7:1.1.1.2 netbsd-9:1.1.1.1.0.2 netbsd-9-base:1.1.1.1 mesa-18-3-6:1.1.1.1 mesa-18-3-4:1.1.1.1 xorg:1.1.1; locks; strict; comment @// @; 1.1 date 2019.03.10.03.42.47; author mrg; state Exp; branches 1.1.1.1; next ; commitid r12jo1Nf3ebQKLeB; 1.1.1.1 date 2019.03.10.03.42.47; author mrg; state Exp; branches; next 1.1.1.2; commitid r12jo1Nf3ebQKLeB; 1.1.1.2 date 2019.09.24.16.43.27; author maya; state Exp; branches; next 1.1.1.3; commitid KJXusGl8fi9AAhEB; 1.1.1.3 date 2022.05.09.01.23.27; author mrg; state Exp; branches; next ; commitid UEBs6hNk81DdQjDD; desc @@ 1.1 log @Initial revision @ text @/* * Copyright © 2011 Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice (including the next * paragraph) shall be included in all copies or substantial portions of the * Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ /** * \file test_optpass.cpp * * Standalone test for optimization passes. * * This file provides the "optpass" command for the standalone * glsl_test app. It accepts either GLSL or high-level IR as input, * and performs the optimiation passes specified on the command line. * It outputs the IR, both before and after optimiations. */ #include #include #include #include #include "ast.h" #include "ir_optimization.h" #include "program.h" #include "ir_reader.h" #include "standalone_scaffolding.h" #include "main/mtypes.h" using namespace std; static string read_stdin_to_eof() { stringbuf sb; cin.get(sb, '\0'); return sb.str(); } static GLboolean do_optimization(struct exec_list *ir, const char *optimization, const struct gl_shader_compiler_options *options) { int int_0; int int_1; int int_2; int int_3; int int_4; if (sscanf(optimization, "do_common_optimization ( %d ) ", &int_0) == 1) { return do_common_optimization(ir, int_0 != 0, false, options, true); } else if (strcmp(optimization, "do_algebraic") == 0) { return do_algebraic(ir, true, options); } else if (strcmp(optimization, "do_constant_folding") == 0) { return do_constant_folding(ir); } else if (strcmp(optimization, "do_constant_variable") == 0) { return do_constant_variable(ir); } else if (strcmp(optimization, "do_constant_variable_unlinked") == 0) { return do_constant_variable_unlinked(ir); } else if (strcmp(optimization, "do_copy_propagation_elements") == 0) { return do_copy_propagation_elements(ir); } else if (strcmp(optimization, "do_constant_propagation") == 0) { return do_constant_propagation(ir); } else if (strcmp(optimization, "do_dead_code") == 0) { return do_dead_code(ir, false); } else if (strcmp(optimization, "do_dead_code_local") == 0) { return do_dead_code_local(ir); } else if (strcmp(optimization, "do_dead_code_unlinked") == 0) { return do_dead_code_unlinked(ir); } else if (strcmp(optimization, "do_dead_functions") == 0) { return do_dead_functions(ir); } else if (strcmp(optimization, "do_function_inlining") == 0) { return do_function_inlining(ir); } else if (sscanf(optimization, "do_lower_jumps ( %d , %d , %d , %d , %d ) ", &int_0, &int_1, &int_2, &int_3, &int_4) == 5) { return do_lower_jumps(ir, int_0 != 0, int_1 != 0, int_2 != 0, int_3 != 0, int_4 != 0); } else if (strcmp(optimization, "do_lower_texture_projection") == 0) { return do_lower_texture_projection(ir); } else if (strcmp(optimization, "do_if_simplification") == 0) { return do_if_simplification(ir); } else if (sscanf(optimization, "lower_if_to_cond_assign ( %d ) ", &int_0) == 1) { return lower_if_to_cond_assign(MESA_SHADER_VERTEX, ir, int_0); } else if (strcmp(optimization, "do_mat_op_to_vec") == 0) { return do_mat_op_to_vec(ir); } else if (strcmp(optimization, "optimize_swizzles") == 0) { return optimize_swizzles(ir); } else if (strcmp(optimization, "do_structure_splitting") == 0) { return do_structure_splitting(ir); } else if (strcmp(optimization, "do_tree_grafting") == 0) { return do_tree_grafting(ir); } else if (strcmp(optimization, "do_vec_index_to_cond_assign") == 0) { return do_vec_index_to_cond_assign(ir); } else if (strcmp(optimization, "do_vec_index_to_swizzle") == 0) { return do_vec_index_to_swizzle(ir); } else if (strcmp(optimization, "lower_discard") == 0) { return lower_discard(ir); } else if (sscanf(optimization, "lower_instructions ( %d ) ", &int_0) == 1) { return lower_instructions(ir, int_0); } else if (strcmp(optimization, "lower_noise") == 0) { return lower_noise(ir); } else if (sscanf(optimization, "lower_variable_index_to_cond_assign " "( %d , %d , %d , %d ) ", &int_0, &int_1, &int_2, &int_3) == 4) { return lower_variable_index_to_cond_assign(MESA_SHADER_VERTEX, ir, int_0 != 0, int_1 != 0, int_2 != 0, int_3 != 0); } else if (sscanf(optimization, "lower_quadop_vector ( %d ) ", &int_0) == 1) { return lower_quadop_vector(ir, int_0 != 0); } else if (strcmp(optimization, "optimize_redundant_jumps") == 0) { return optimize_redundant_jumps(ir); } else { printf("Unrecognized optimization %s\n", optimization); exit(EXIT_FAILURE); return false; } } static GLboolean do_optimization_passes(struct exec_list *ir, char **optimizations, int num_optimizations, bool quiet, const struct gl_shader_compiler_options *options) { GLboolean overall_progress = false; for (int i = 0; i < num_optimizations; ++i) { const char *optimization = optimizations[i]; if (!quiet) { printf("*** Running optimization %s...", optimization); } GLboolean progress = do_optimization(ir, optimization, options); if (!quiet) { printf("%s\n", progress ? "progress" : "no progress"); } validate_ir_tree(ir); overall_progress = overall_progress || progress; } return overall_progress; } int test_optpass(int argc, char **argv) { int input_format_ir = 0; /* 0=glsl, 1=ir */ int loop = 0; int shader_type = GL_VERTEX_SHADER; int quiet = 0; const struct option optpass_opts[] = { { "input-ir", no_argument, &input_format_ir, 1 }, { "input-glsl", no_argument, &input_format_ir, 0 }, { "loop", no_argument, &loop, 1 }, { "vertex-shader", no_argument, &shader_type, GL_VERTEX_SHADER }, { "fragment-shader", no_argument, &shader_type, GL_FRAGMENT_SHADER }, { "quiet", no_argument, &quiet, 1 }, { NULL, 0, NULL, 0 } }; int idx = 0; int c; while ((c = getopt_long(argc, argv, "", optpass_opts, &idx)) != -1) { if (c != 0) { printf("*** usage: %s optpass \n", argv[0]); printf("\n"); printf("Possible options are:\n"); printf(" --input-ir: input format is IR\n"); printf(" --input-glsl: input format is GLSL (the default)\n"); printf(" --loop: run optimizations repeatedly until no progress\n"); printf(" --vertex-shader: test with a vertex shader (the default)\n"); printf(" --fragment-shader: test with a fragment shader\n"); exit(EXIT_FAILURE); } } struct gl_context local_ctx; struct gl_context *ctx = &local_ctx; initialize_context_to_defaults(ctx, API_OPENGL_COMPAT); ir_variable::temporaries_allocate_names = true; struct gl_shader *shader = rzalloc(NULL, struct gl_shader); shader->Type = shader_type; shader->Stage = _mesa_shader_enum_to_shader_stage(shader_type); string input = read_stdin_to_eof(); struct _mesa_glsl_parse_state *state = new(shader) _mesa_glsl_parse_state(ctx, shader->Stage, shader); if (input_format_ir) { shader->ir = new(shader) exec_list; _mesa_glsl_initialize_types(state); _mesa_glsl_read_ir(state, shader->ir, input.c_str(), true); } else { shader->Source = input.c_str(); const char *source = shader->Source; state->error = glcpp_preprocess(state, &source, &state->info_log, NULL, NULL, ctx) != 0; if (!state->error) { _mesa_glsl_lexer_ctor(state, source); _mesa_glsl_parse(state); _mesa_glsl_lexer_dtor(state); } shader->ir = new(shader) exec_list; if (!state->error && !state->translation_unit.is_empty()) _mesa_ast_to_hir(shader->ir, state); } /* Print out the initial IR */ if (!state->error && !quiet) { printf("*** pre-optimization IR:\n"); _mesa_print_ir(stdout, shader->ir, state); printf("\n--\n"); } /* Optimization passes */ if (!state->error) { GLboolean progress; const struct gl_shader_compiler_options *options = &ctx->Const.ShaderCompilerOptions[_mesa_shader_enum_to_shader_stage(shader_type)]; do { progress = do_optimization_passes(shader->ir, &argv[optind], argc - optind, quiet != 0, options); } while (loop && progress); } /* Print out the resulting IR */ if (!state->error) { if (!quiet) { printf("*** resulting IR:\n"); } _mesa_print_ir(stdout, shader->ir, state); if (!quiet) { printf("\n--\n"); } } if (state->error) { printf("*** error(s) occurred:\n"); printf("%s\n", state->info_log); printf("--\n"); } ralloc_free(state); ralloc_free(shader); return state->error; } @ 1.1.1.1 log @from maya: Import mesa 18.3.4. Mesa 18.3.4 implements the OpenGL 4.5 API. Some drivers don't support all the features required in OpenGL 4.5. @ text @@ 1.1.1.2 log @Import mesa 19.1.7 New features in mesa 19.1.0: GL_ARB_parallel_shader_compile on all drivers. GL_EXT_gpu_shader4 on all GL 3.1 drivers. GL_EXT_shader_image_load_formatted on radeonsi. GL_EXT_texture_buffer_object on all GL 3.1 drivers. GL_EXT_texture_compression_s3tc_srgb on Gallium drivers and i965 (ES extension). GL_NV_compute_shader_derivatives on iris and i965. GL_KHR_parallel_shader_compile on all drivers. VK_EXT_buffer_device_address on Intel and RADV. VK_EXT_depth_clip_enable on Intel and RADV. VK_KHR_ycbcr_image_arrays on Intel. VK_EXT_inline_uniform_block on Intel and RADV. VK_EXT_external_memory_host on Intel. VK_EXT_host_query_reset on Intel and RADV. VK_KHR_surface_protected_capabilities on Intel and RADV. VK_EXT_pipeline_creation_feedback on Intel and RADV. VK_KHR_8bit_storage on RADV. VK_AMD_gpu_shader_int16 on RADV. VK_AMD_gpu_shader_half_float on RADV. VK_NV_compute_shader_derivatives on Intel. VK_KHR_shader_float16_int8 on Intel and RADV (RADV only supports int8). VK_KHR_shader_atomic_int64 on Intel. VK_EXT_descriptor_indexing on Intel. VK_KHR_shader_float16_int8 on Intel and RADV. GL_INTEL_conservative_rasterization on iris. VK_EXT_memory_budget on Intel. New features in mesa 19.0.0: GL_AMD_texture_texture4 on all GL 4.0 drivers. GL_EXT_shader_implicit_conversions on all drivers (ES extension). GL_EXT_texture_compression_bptc on all GL 4.0 drivers (ES extension). GL_EXT_texture_compression_rgtc on all GL 3.0 drivers (ES extension). GL_EXT_render_snorm on gallium drivers (ES extension). GL_EXT_texture_view on drivers supporting texture views (ES extension). GL_OES_texture_view on drivers supporting texture views (ES extension). GL_NV_shader_atomic_float on nvc0 (Fermi/Kepler only). Shader-based software implementations of GL_ARB_gpu_shader_fp64, GL_ARB_gpu_shader_int64, GL_ARB_vertex_attrib_64bit, and GL_ARB_shader_ballot on i965. VK_ANDROID_external_memory_android_hardware_buffer on Intel Fixed and re-exposed VK_EXT_pci_bus_info on Intel and RADV VK_EXT_scalar_block_layout on Intel and RADV VK_KHR_depth_stencil_resolve on Intel VK_KHR_draw_indirect_count on Intel VK_EXT_conditional_rendering on Intel VK_EXT_memory_budget on RADV Also, bug fixes. @ text @a168 1 int error; a266 2 error = state->error; d270 1 a270 1 return error; @ 1.1.1.3 log @initial import of mesa 21.3.7 main changes since 19.1.7 include: - more support for Vulkan functions - better supported for newer radeonsi (both amdgpu and radeon backends) - various bug fixes in many drivers - many fixes and enhancements for intel drivers - some fixes for nvidia - OpenGL 4.6 for some drivers (intel, radeonsi) - intel Tigerlake and Rocketlake support - Vulkan 1.2 for some drivers - OpenGL 4.5, GLES 3.2, and more on llvmpipe - working Panfrost and Midgard drivers - fix warnings in radeonsi vs newer llvm @ text @d95 2 d119 2 @