summaryrefslogtreecommitdiff
path: root/tests.d/vulkan/vktrace_validate.test
blob: 3ba9d2f9864e35f08df296c0f7a4d8739ed60213 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# Parameters:
# - VKREPLAY_BINARY: VulkanTools tool for replaying traces
# - VKREPLAY_TRACE_FOLDER
#
# Trace folder should contain:
# - trace files named as: <name>.vktrace
# - trace frame files named as: <name>.vktrace.validate
#   - contains comma separated list of frames to validate
# For example:
# - dota2-tutorial:1080p:high.vktrace
# - dota2-tutorial:1080p:high.vktrace.validate
#
# Convention is to separate test-case name, resolution and render quality level
# in <name> with a colon character.

test -d "${VKREPLAY_TRACE_FOLDER}" || return 1
test -x "${VKREPLAY_BINARY}" || return 1

# 1 argument: $trace
function __vkreplay_validate_run__ {
    local trace=$1
    local frame
    local oldname
    local newname
    local sha
    output=${run_log_file}_tmp

    mkdir -p "$output"
    pushd "$output" >/dev/null

    # for now, vktrace supports just one frame
    frame=$(head -1 "${trace}.validate"|cut -d, -f1)

    run_bench 0 "${VKREPLAY_BINARY}" -s ${frame}-1-1 -o "$trace" >/dev/null 2>&1
    oldname=$frame.ppm
    if [ \! -f "$oldname" ]; then
        touch "$oldname"
	echo "ERROR: no image; Vulkan replay failure, or screenshot layer missing!" 1>&2
    fi

    # store file under its own SHA to get free de-duplication
    sha=$(sha1sum $oldname | cut -d' ' -f1)
    newname=$sha.png
    convert $oldname ../$newname

    echo "$frame,$newname"

    popd >/dev/null
    rm -r "$output"
}

for framefile in "${VKREPLAY_TRACE_FOLDER}/"*.validate; do
    trace=${framefile%.validate}
    test -f "$trace" || continue

    name=${trace##*/}
    name="vkreplay:validate:${name%.vktrace}"
    eval "${name}_run() { __vkreplay_validate_run__ ${trace}; }"

    test_name="$test_name $name"
done

# can't know how much arbitrary trace file takes
test_exec_time=10

# smaller diff is better
test_invert=1

# for image validation
test_unit="imgs"
test_type="imgval"