4 #include "pipe/p_context.h"
5 #include "pipe/p_screen.h"
6 #include "pipe/p_defines.h"
7 #include "pipe/p_inlines.h"
8 #include "pipe/p_state.h"
10 #include "st_context.h"
11 #include "st_texture.h"
12 #include "st_public.h"
14 static INLINE
struct pipe_transfer
*
15 st_cond_flush_get_tex_transfer(struct st_context
*st
,
16 struct pipe_texture
*pt
,
20 enum pipe_transfer_usage usage
,
21 unsigned int x
, unsigned int y
,
22 unsigned int w
, unsigned int h
)
24 struct pipe_screen
*screen
= st
->pipe
->screen
;
26 st_teximage_flush_before_map(st
, pt
, face
, level
, usage
);
27 return screen
->get_tex_transfer(screen
, pt
, face
, level
, zslice
, usage
,
31 static INLINE
struct pipe_transfer
*
32 st_no_flush_get_tex_transfer(struct st_context
*st
,
33 struct pipe_texture
*pt
,
37 enum pipe_transfer_usage usage
,
38 unsigned int x
, unsigned int y
,
39 unsigned int w
, unsigned int h
)
41 struct pipe_screen
*screen
= st
->pipe
->screen
;
43 return screen
->get_tex_transfer(screen
, pt
, face
, level
,
44 zslice
, usage
, x
, y
, w
, h
);
48 st_cond_flush_pipe_buffer_map(struct st_context
*st
,
49 struct pipe_buffer
*buf
,
50 unsigned int map_flags
)
52 struct pipe_context
*pipe
= st
->pipe
;
53 unsigned int referenced
= pipe
->is_buffer_referenced(pipe
, buf
);
55 if (referenced
&& ((referenced
& PIPE_REFERENCED_FOR_WRITE
) ||
56 (map_flags
& PIPE_BUFFER_USAGE_CPU_WRITE
)))
57 st_flush(st
, PIPE_FLUSH_RENDER_CACHE
, NULL
);
59 return pipe_buffer_map(pipe
->screen
, buf
, map_flags
);
63 st_no_flush_pipe_buffer_map(struct st_context
*st
,
64 struct pipe_buffer
*buf
,
65 unsigned int map_flags
)
67 return pipe_buffer_map(st
->pipe
->screen
, buf
, map_flags
);
72 st_cond_flush_pipe_buffer_write(struct st_context
*st
,
73 struct pipe_buffer
*buf
,
78 struct pipe_context
*pipe
= st
->pipe
;
80 if (pipe
->is_buffer_referenced(pipe
, buf
))
81 st_flush(st
, PIPE_FLUSH_RENDER_CACHE
, NULL
);
83 pipe_buffer_write(pipe
->screen
, buf
, offset
, size
, data
);
87 st_no_flush_pipe_buffer_write(struct st_context
*st
,
88 struct pipe_buffer
*buf
,
93 pipe_buffer_write(st
->pipe
->screen
, buf
, offset
, size
, data
);
97 st_cond_flush_pipe_buffer_read(struct st_context
*st
,
98 struct pipe_buffer
*buf
,
103 struct pipe_context
*pipe
= st
->pipe
;
105 if (pipe
->is_buffer_referenced(pipe
, buf
) & PIPE_REFERENCED_FOR_WRITE
)
106 st_flush(st
, PIPE_FLUSH_RENDER_CACHE
, NULL
);
108 pipe_buffer_read(pipe
->screen
, buf
, offset
, size
, data
);
112 st_no_flush_pipe_buffer_read(struct st_context
*st
,
113 struct pipe_buffer
*buf
,
118 pipe_buffer_read(st
->pipe
->screen
, buf
, offset
, size
, data
);