Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4501 Serge 1
/*
2
 * Copyright © 2011-2013 Intel Corporation
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
 * Authors:
24
 *    Chris Wilson 
25
 *
26
 */
27
 
28
#ifndef GEN6_COMMON_H
29
#define GEN6_COMMON_H
30
 
31
#include "sna.h"
32
 
33
#define NO_RING_SWITCH 0
34
#define PREFER_RENDER 0
35
 
36
static inline bool is_uncached(struct sna *sna,
37
			       struct kgem_bo *bo)
38
{
39
	return bo->scanout && !sna->kgem.has_wt;
40
}
41
 
42
inline static bool can_switch_to_blt(struct sna *sna,
43
				     struct kgem_bo *bo,
44
				     unsigned flags)
45
{
46
    return false;
47
}
48
 
49
inline static bool can_switch_to_render(struct sna *sna,
50
					struct kgem_bo *bo)
51
{
52
	if (sna->kgem.ring == KGEM_RENDER)
53
		return true;
54
 
55
	if (NO_RING_SWITCH)
56
		return false;
57
 
58
	if (!sna->kgem.has_semaphores)
59
		return false;
60
 
61
	if (bo && !RQ_IS_BLT(bo->rq) && !is_uncached(sna, bo))
62
		return true;
63
 
64
	return !kgem_ring_is_idle(&sna->kgem, KGEM_RENDER);
65
}
66
 
67
static inline bool untiled_tlb_miss(struct kgem_bo *bo)
68
{
69
	if (kgem_bo_is_render(bo))
70
		return false;
71
 
72
	return bo->tiling == I915_TILING_NONE && bo->pitch >= 4096;
73
}
74
 
75
static int prefer_blt_bo(struct sna *sna, struct kgem_bo *bo)
76
{
77
	if (bo->rq)
78
		return RQ_IS_BLT(bo->rq);
79
 
80
	if (sna->flags & SNA_POWERSAVE)
81
		return true;
82
 
83
	return bo->tiling == I915_TILING_NONE || is_uncached(sna, bo);
84
}
85
 
86
inline static bool force_blt_ring(struct sna *sna)
87
{
88
	if (sna->flags & SNA_POWERSAVE)
89
		return true;
90
 
91
	if (sna->kgem.mode == KGEM_RENDER)
92
		return false;
93
 
94
	if (sna->render_state.gt < 2)
95
		return true;
96
 
97
	return false;
98
}
99
 
100
inline static bool prefer_blt_ring(struct sna *sna,
101
				   struct kgem_bo *bo,
102
				   unsigned flags)
103
{
104
	assert(!force_blt_ring(sna));
105
	assert(!kgem_bo_is_render(bo));
106
 
107
	return can_switch_to_blt(sna, bo, flags);
108
}
109
 
110
inline static bool prefer_render_ring(struct sna *sna,
111
				      struct kgem_bo *bo)
112
{
113
	if (sna->flags & SNA_POWERSAVE)
114
		return false;
115
 
116
	if (sna->render_state.gt < 2)
117
		return false;
118
 
119
	return can_switch_to_render(sna, bo);
120
}
121
 
122
inline static bool
123
prefer_blt_composite(struct sna *sna, struct sna_composite_op *tmp)
124
{
125
    return false;
126
 
127
}
128
 
129
static inline bool prefer_blt_fill(struct sna *sna,
130
				   struct kgem_bo *bo,
131
				   unsigned flags)
132
{
133
        return false;
134
}
135
 
136
void gen6_render_context_switch(struct kgem *kgem, int new_mode);
137
void gen6_render_retire(struct kgem *kgem);
138
 
139
#endif /* GEN6_COMMON_H */