Differential D36213 Diff 109601 graphics/igt-gpu-tools/files/patch-scripts_generate__clear__kernel.sh
Changeset View
Changeset View
Standalone View
Standalone View
graphics/igt-gpu-tools/files/patch-scripts_generate__clear__kernel.sh
- This file was added.
--- scripts/generate_clear_kernel.sh.orig 2022-08-17 23:41:17 UTC | |||||
+++ scripts/generate_clear_kernel.sh | |||||
@@ -1,4 +1,4 @@ | |||||
-#!/bin/bash | |||||
+#!/bin/sh | |||||
# | |||||
# SPDX-License-Identifier: MIT | |||||
# | |||||
@@ -25,7 +25,7 @@ export ASSEMBLY_SOURCE=./lib/i915/shaders/clear_kernel | |||||
export ASSEMBLY_SOURCE=./lib/i915/shaders/clear_kernel | |||||
-function get_help { | |||||
+get_help() { | |||||
echo "Usage: ${0} [options]" | |||||
echo "Note: hsw_clear_kernel.c/ivb_clear_kernel.c automatically generated by this script should never be modified - it would be imported to i915, to use as it is..." | |||||
echo " " | |||||
@@ -40,14 +40,14 @@ function get_help { | |||||
echo " Usage example: \"./scripts/generate_clear_kernel.sh -g hsw -o hsw_clear_buffer.h -m ~/mesa/build/src/intel/tools/i965_asm\"" | |||||
} | |||||
-function include_array # $1=array_name - update Mesa output with desired format | |||||
+include_array() # $1=array_name - update Mesa output with desired format | |||||
{ | |||||
array_declaration="static const u32 $(basename $1)_clear_kernel[] = {" | |||||
close_array=";" | |||||
sed -i "1s/.*/$array_declaration/" $output_file | |||||
sed -i "$ s/$/$close_array/" $output_file | |||||
} | |||||
-function prefix_header # $1=filename $2=comment | |||||
+prefix_header() # $1=filename $2=comment | |||||
{ | |||||
cat <<EOF | |||||
// SPDX-License-Identifier: MIT | |||||
@@ -60,21 +60,21 @@ EOF | |||||
EOF | |||||
} | |||||
-function check_output_file #check output file | |||||
+check_output_file() #check output file | |||||
{ | |||||
if [ "x$output_file" != "x" ]; then | |||||
if [ -f "$output_file" ]; then | |||||
- echo -e "Warning: The \"$output_file\" file already exist - choose another file\n" | |||||
+ printf 'Warning: The "%s" file already exist - choose another file\n' "$output_file" | |||||
get_help | |||||
exit 1 | |||||
fi | |||||
else | |||||
# It is okay to overwrite default file created | |||||
- echo -e "Output file not specified - using default file \"$gen_device-cb_assembled\"\n" | |||||
output_file="$gen_device-cb_assembled" | |||||
+ printf 'Output file not specified - using default file "%s"\n' "$output_file" | |||||
fi | |||||
} | |||||
-function asm_cb_kernel # as-root <args> | |||||
+asm_cb_kernel() # as-root <args> | |||||
{ | |||||
check_output_file | |||||
@@ -82,22 +82,22 @@ function asm_cb_kernel # as-root <args> | |||||
$mesa_i965_asm -g $gen_device -t c_literal $input_asm_source -o $output_file | |||||
if [ ! -f ${output_file} ]; then | |||||
- echo -e "Failed to assemble CB Kernel with Mesa tool\n" | |||||
+ printf "Failed to assemble CB Kernel with Mesa tool\n" | |||||
get_help | |||||
exit 1 | |||||
fi | |||||
# Generate header file | |||||
- if [ "$gen_device" == "hsw" ]; then | |||||
- echo "Generating gen7.5 CB Kernel assembled file \"hsw_clear_kernel.c\" for i915 driver..." | |||||
+ if [ "$gen_device" = "hsw" ]; then | |||||
+ printf 'Generating gen7.5 CB Kernel assembled file "hsw_clear_kernel.c" for i915 driver...' | |||||
i915_filename=hsw_clear_kernel.c | |||||
include_array $gen_device | |||||
prefix_header > $i915_filename | |||||
cat $output_file >> $i915_filename | |||||
- elif [ "$gen_device" == "ivb" ]; then | |||||
- echo "Generating gen7 CB Kernel assembled file \"ivb_clear_kernel.c\" for i915 driver..." | |||||
+ elif [ "$gen_device" = "ivb" ]; then | |||||
+ printf 'Generating gen7 CB Kernel assembled file "ivb_clear_kernel.c" for i915 driver...' | |||||
i915_filename=ivb_clear_kernel.c | |||||
include_array $gen_device | |||||
@@ -113,7 +113,7 @@ while getopts "hg:o:m:" opt; do | |||||
o) output_file="$OPTARG" ;; | |||||
m) mesa_i965_asm="$OPTARG" ;; | |||||
\?) | |||||
- echo -e "Unknown option: -$OPTARG\n" | |||||
+ printf "Unknown option: -%s\n" "$OPTARG" | |||||
get_help | |||||
exit 1 | |||||
;; | |||||
@@ -122,30 +122,30 @@ if [ "x$1" != "x" ]; then | |||||
shift $(($OPTIND-1)) | |||||
if [ "x$1" != "x" ]; then | |||||
- echo -e "Unknown option: $1\n" | |||||
+ printf "Unknown option: %s\n" "$1" | |||||
get_help | |||||
exit 1 | |||||
fi | |||||
-if [ "x$mesa_i965_asm" == "x" ]; then | |||||
- echo -e "i965_asm binary not found\n" | |||||
+if [ "x$mesa_i965_asm" = "x" ]; then | |||||
+ printf "i965_asm binary not found\n" | |||||
get_help | |||||
exit 1 | |||||
fi | |||||
if [ "x$gen_device" != "x" ]; then | |||||
- if [ "$gen_device" == "hsw" ]; then | |||||
+ if [ "$gen_device" = "hsw" ]; then | |||||
input_asm_source="${ASSEMBLY_SOURCE}/hsw.asm" | |||||
- elif [ "$gen_device" == "ivb" ]; then | |||||
+ elif [ "$gen_device" = "ivb" ]; then | |||||
input_asm_source="${ASSEMBLY_SOURCE}/ivb.asm" | |||||
else | |||||
- echo -e "Unknown platform specified\n" | |||||
+ printf "Unknown platform specified\n" | |||||
get_help | |||||
exit 1 | |||||
fi | |||||
asm_cb_kernel | |||||
else | |||||
- echo -e "Platform generation not specified\n" | |||||
+ printf "Platform generation not specified\n" | |||||
get_help | |||||
exit 1 | |||||
fi |