summaryrefslogtreecommitdiff
path: root/README.md
blob: 0933c37bfc148159ffa2473f269327221e079b2c (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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
Shader-db: A collection of shaders for offline analysis
=======================================================

Shader-db is a giant pile of shaders from various apps, for whatever purpose.
In particular, we use it to capture assembly output of the shader compiler for
analysis of regressions in compiler behavior.

Currently it supports Mesa's i965 and radeonsi drivers.


## Capturing shaders

Create the directory for shader files

    $ mkdir dirpath

Write all shaders that are loaded by "executable" to the directory

    $ MESA_SHADER_CAPTURE_PATH=<dirpath> <executable>

Use `fdupes` can be used to remove duplicates

    $ fdupes -d <dirpath>


## Compiling

Some libraries are required when building. See section "Dependencies" below.
To build the binary, do:
make

## i965/iris Usage

### Running shaders

    $ ./run shaders 2> err | tee new-run

### To run just a subset:

    $ ./run shaders/supertuxkart 2> err | tee new-run

## Running for another platform, use intel_stub_gpu (from Mesa repository) :

    $ intel_stub_gpu -p icl ./run shaders 2> err | tee new-run

Make sure to check the contents of 'err' after your run.

To compile shaders for an i965 PCI ID different from your system, pass

	-p {i965,g4x,ilk,snb,ivb,hsw,byt,bdw}

to `run`.


### Analysis

    $ ./report.py old-run new-run


## radeonsi Usage

### Running shaders

    $ ./run shaders > new-run 2> /dev/null

Note that a debug mesa build required (ie. `--enable-debug`)


### Analysis

./si-report.py old-run new-run


## freedreno, v3d Usage

### Running shaders

    $ ./run shaders > new-run

Note that a debug mesa build required (ie. `--enable-debug`)

### Analysis

./report.py old-run new-run


## Dependencies

run requires some GNU C extensions, render nodes (/dev/dri/renderD128),
libepoxy, OpenMP, and Mesa configured with `--with-egl-platforms=x11,drm`


## jemalloc

Since run compiles shaders in different threads, malloc/free locking overhead
from inside Mesa can be expensive. Preloading jemalloc can cut significant
amounts of time:

    $ LD_PRELOAD=/usr/lib64/libjemalloc.so.1 ./run shaders 2> err | tee new-run


## Deprecated

`run.py` is obsolete. Use the `run` binary instead.


# Vulkan Fossils

shader-db also contains a selection of vulkan fossils. These are generated
using the fossilize.sh script and [fossil](https://github.com/ValveSoftware/Fossilize).

You will need a vulkan driver with pipeline statistics:

    $ fossilize-replay --enable-pipeline-stats output.csv --num-threads 4 fossils/**/*.foz

Or you can use a helper script to do this:

    $ ./fossil_replay.sh fossils/ output.csv --num-threads 4

Or you can use fossil_prune_replay.sh to replay a specific pipeline by hash:

    $ ./fossil_prune_replay.sh fossils/ 012897d03e30f26f

If you do not get a .csv file it likely means that a driver without
`VK_KHR_pipeline_statistics`, such as a system installed driver.

You can then compare two different csv files using the report-fossil.py script:

    $ report-fossil.py baseline.csv development.csv

## Capturing fossils

A fossilize.sh script is provided to assist in capturing fossils, you may
need to modify it based on where fossil lives on your system.

For steam games, fossils are currently captured automatically.  Once the game
has been run for a while, you can find the fossils at
`$HOME/.local/share/Steam/steamapps/shadercache/$APP_ID/fozpipelinesv4/steamapp_pipeline_cache.foz`.
Note that you need to use the file named `steamapp_pipeline_cache.foz` and not
the fossil file named `steam_*` because the later one may contain fossilized
pipelines from other drivers which may use extensions not supported by your
driver.  The `steamapp_pipeline_cache.foz` file contains only those pipelines
which have actually been seen during the run on your actual driver.