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
144
145
|
/*
* Copyright 2012 Red Hat Inc.
*
* 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
* on the rights to use, copy, modify, merge, publish, distribute, sub
* license, 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 NON-INFRINGEMENT. IN NO EVENT SHALL
* THE AUTHOR(S) AND/OR THEIR SUPPLIERS 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.
*
* Authors:
* Jerome Glisse
*/
#ifndef REPLAYX_H
#define REPLAYX_H
#include <xcb/xcb.h>
#include <xcb/xcb_aux.h>
#include <xcb/dri2.h>
#include <xcb/xfixes.h>
#include <stdint.h>
#include <rati_file.h>
#include "r6xx.h"
struct ctx;
struct ctx_bo {
unsigned w;
unsigned h;
unsigned flags;
unsigned pitch;
unsigned name;
unsigned cpp;
unsigned handle;
unsigned size;
unsigned alignment;
unsigned mapcount;
void *data;
unsigned format;
unsigned hw_format;
unsigned hw_tile;
};
struct radeon_cs_reloc {
uint32_t handle;
uint32_t read_domain;
uint32_t write_domain;
uint32_t flags;
};
struct r6xx_blit {
uint32_t *cs;
unsigned cdw;
struct ctx *ctx;
struct ctx_bo shader_bo;
struct radeon_cs_reloc relocs[3];
struct r6xx_sq_conf sq_conf;
unsigned vs_offset;
unsigned ps_offset;
unsigned vbo_offset;
unsigned ps_size;
unsigned vs_size;
};
union ctx_blit {
struct r6xx_blit r6xx;
};
typedef int (*drv_compatible_t)(struct ctx *ctx);
typedef int (*drv_blit_init_t)(struct ctx *ctx);
typedef void (*drv_blit_fini_t)(struct ctx *ctx);
typedef int (*drv_blit_t)(struct ctx *ctx, struct ctx_bo *bo);
struct ctx_drv {
drv_compatible_t compatible;
drv_blit_init_t blit_init;
drv_blit_fini_t blit_fini;
drv_blit_t blit;
};
struct ctx {
xcb_connection_t *con;
xcb_window_t root;
xcb_window_t window;
int screen_num;
xcb_visualid_t visual_id;
unsigned depth;
unsigned win_w;
unsigned win_h;
char *device_name;
int fd;
struct ctx_bo front;
struct rati_file rfile;
struct radeon_cs_reloc *relocs;
struct ctx_bo *bos;
unsigned nbos;
unsigned family;
struct ctx_drv drv;
uint32_t pciid;
union ctx_blit blit;
struct ctx_bo *target[64];
unsigned ntarget;
unsigned ctarget;
};
int ctx_bo(struct ctx *ctx, struct ctx_bo *bo, void *data);
int ctx_bo_map(struct ctx *ctx, struct ctx_bo *bo);
void ctx_bo_unmap(struct ctx_bo *bo);
void ctx_bo_free(struct ctx *ctx, struct ctx_bo *bo);
int ctx_bo_wait(struct ctx *ctx, struct ctx_bo *bo);
int ctx_rati_load(struct ctx *ctx, const char *filename);
int ctx_cs_rati(struct ctx *ctx);
int ctx_cs(struct ctx *ctx, void *cs, unsigned ndw, void *relocs, unsigned nrelocs);
int ctx_drv_init(struct ctx *ctx);
void ctx_drv_fini(struct ctx *ctx);
extern const struct ctx_drv _r6xx_drv;
static inline unsigned fui(float f)
{
union {
float f;
unsigned u;
} c;
c.f = f;
return c.u;
}
#endif
|