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
|
/*
* Copyright (c) 2012-2013 Etnaviv Project
*
* 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
* 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 AUTHORS OR COPYRIGHT HOLDERS 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.
*/
/* Utilities for framebuffer demos */
#ifndef H_FBDEMOS
#define H_FBDEMOS
#include <etnaviv/etna_fb.h>
#include "etna_bswap.h"
#define ETNA_FB_MAX_BUFFERS (2) /* double buffering is enough */
struct pipe_resource;
struct fb_info
{
int fd;
int num_buffers;
/* GPU addresses of buffers */
size_t physical[ETNA_FB_MAX_BUFFERS];
/* CPU addresses of buffers */
void *logical[ETNA_FB_MAX_BUFFERS];
size_t stride;
size_t buffer_stride;
struct fb_var_screeninfo fb_var;
struct fb_fix_screeninfo fb_fix;
void *map;
struct etna_resource *resource;
struct compiled_rs_state copy_to_screen[ETNA_FB_MAX_BUFFERS];
/* Resolve format (-1 if no match), and swap red/blue bit */
int rs_format;
bool swap_rb;
};
struct fbdemos_scaffold
{
int width;
int height;
struct fb_info fb;
struct viv_conn *conn;
struct etna_ctx *ctx;
struct pipe_context *pipe;
struct etna_bswap_buffers *buffers;
struct pipe_screen *screen;
};
void fbdemo_init(struct fbdemos_scaffold **out);
void fbdemo_free(struct fbdemos_scaffold *fbs);
struct pipe_resource *fbdemo_create_2d(struct pipe_screen *screen, unsigned flags, unsigned format, unsigned width, unsigned height, unsigned max_mip_level);
struct pipe_resource *fbdemo_create_cube(struct pipe_screen *screen, unsigned flags, unsigned format, unsigned width, unsigned height, unsigned max_mip_level);
/**
* One-shot write to texture or buffer, similar to gallium transfer_inline_write but somewhat more limited right now.
* Does tiling if needed.
* XXX no stride parameter, assumes that data is tightly packed.
*/
void etna_pipe_inline_write(struct pipe_context *pipe, struct pipe_resource *resource, unsigned layer, unsigned level, void *data, size_t size);
void etna_convert_r8g8b8_to_b8g8r8x8(uint32_t *dst, const uint8_t *src, unsigned num_pixels);
/* Open framebuffer and get information */
int fb_open(int num, struct fb_info *out);
/* Set currently visible buffer id */
int fb_set_buffer(struct fb_info *fb, int buffer);
/* Close framebuffer */
int fb_close(struct fb_info *fb);
/* Bind framebuffer to render target resource */
int etna_fb_bind_resource(struct fb_info *fb, struct pipe_resource *rt_resource);
/* Copy framebuffer from bound render target resource */
int etna_fb_copy_buffer(struct fb_info *fb, struct etna_ctx *ctx, int buffer);
#endif
|