• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright © 2012 Rob Clark <robclark@freedesktop.org>
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice (including the next
12  * paragraph) shall be included in all copies or substantial portions of the
13  * Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21  * SOFTWARE.
22  */
23 
24 #ifndef REDUMP_H_
25 #define REDUMP_H_
26 
27 #include <unistd.h>
28 
29 enum rd_sect_type {
30    RD_NONE,
31    RD_TEST,           /* ascii text */
32    RD_CMD,            /* ascii text */
33    RD_GPUADDR,        /* u32 gpuaddr, u32 size */
34    RD_CONTEXT,        /* raw dump */
35    RD_CMDSTREAM,      /* raw dump */
36    RD_CMDSTREAM_ADDR, /* gpu addr of cmdstream */
37    RD_PARAM,          /* u32 param_type, u32 param_val, u32 bitlen */
38    RD_FLUSH,          /* empty, clear previous params */
39    RD_PROGRAM,        /* shader program, raw dump */
40    RD_VERT_SHADER,
41    RD_FRAG_SHADER,
42    RD_BUFFER_CONTENTS,
43    RD_GPU_ID,
44    RD_CHIP_ID,
45    RD_SHADER_LOG_BUFFER, /* Specifies buffer which has logs from shaders */
46    RD_CP_LOG_BUFFER, /* Specifies buffer which has logs from CP */
47    RD_WRBUFFER,     /* Specifies buffer which has data that needs to be written out to a file */
48 };
49 
50 /* RD_PARAM types: */
51 enum rd_param_type {
52    RD_PARAM_SURFACE_WIDTH,
53    RD_PARAM_SURFACE_HEIGHT,
54    RD_PARAM_SURFACE_PITCH,
55    RD_PARAM_COLOR,
56    RD_PARAM_BLIT_X,
57    RD_PARAM_BLIT_Y,
58    RD_PARAM_BLIT_WIDTH,
59    RD_PARAM_BLIT_HEIGHT,
60    RD_PARAM_BLIT_X2, /* BLIT_X + BLIT_WIDTH */
61    RD_PARAM_BLIT_Y2, /* BLIT_Y + BLIT_WIDTH */
62 };
63 
64 static inline void
rd_write_section(int fd,enum rd_sect_type type,const void * buf,int sz)65 rd_write_section(int fd, enum rd_sect_type type, const void *buf, int sz)
66 {
67    write(fd, &type, 4);
68    write(fd, &sz, 4);
69    write(fd, buf, sz);
70 }
71 
72 #endif /* REDUMP_H_ */
73