2
* Copyright (C) 2008-2010 Advanced Micro Devices, Inc.
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:
11
* The above copyright notice and this permission notice shall be included
12
* in all copies or substantial portions of the Software.
14
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17
* THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
* Richard Li <RichardZ.Li@amd.com>, <richardradeon@gmail.com>
27
#include "main/glheader.h"
28
#include "main/api_arrayelt.h"
29
#include "main/context.h"
30
#include "main/simple_list.h"
31
#include "main/imports.h"
32
#include "main/bufferobj.h"
33
#include "main/texobj.h"
35
#include "radeon_common_context.h"
36
#include "evergreen_context.h"
37
#include "evergreen_state.h"
38
#include "evergreen_blit.h"
39
#include "r600_cmdbuf.h"
40
#include "radeon_queryobj.h"
42
static void evergreen_get_lock(radeonContextPtr rmesa)
44
drm_radeon_sarea_t *sarea = rmesa->sarea;
46
if (sarea->ctx_owner != rmesa->dri.hwContext) {
47
sarea->ctx_owner = rmesa->dri.hwContext;
48
if (!rmesa->radeonScreen->kernel_mm)
49
radeon_bo_legacy_texture_age(rmesa->radeonScreen->bom);
53
static void evergreen_vtbl_emit_cs_header(struct radeon_cs *cs, radeonContextPtr rmesa)
55
/* please flush pipe do all pending work */
59
static void evergreen_vtbl_pre_emit_atoms(radeonContextPtr radeon)
61
r700Start3D((context_t *)radeon);
64
static void evergreen_fallback(struct gl_context *ctx, GLuint bit, GLboolean mode)
66
context_t *context = EVERGREEN_CONTEXT(ctx);
68
context->radeon.Fallback |= bit;
70
context->radeon.Fallback &= ~bit;
73
static void evergreen_emit_query_finish(radeonContextPtr radeon)
75
context_t *context = (context_t*) radeon;
76
BATCH_LOCALS(&context->radeon);
78
struct radeon_query_object *query = radeon->query.current;
80
BEGIN_BATCH_NO_AUTOSTATE(4 + 2);
81
R600_OUT_BATCH(CP_PACKET3(R600_IT_EVENT_WRITE, 2));
82
R600_OUT_BATCH(R600_EVENT_TYPE(ZPASS_DONE) | R600_EVENT_INDEX(1));
83
R600_OUT_BATCH(query->curr_offset + 8); /* hw writes qwords */
84
R600_OUT_BATCH(0x00000000);
85
R600_OUT_BATCH_RELOC(VGT_EVENT_INITIATOR, query->bo, 0, 0, RADEON_GEM_DOMAIN_GTT, 0);
87
assert(query->curr_offset < RADEON_QUERY_PAGE_SIZE);
88
query->emitted_begin = GL_FALSE;
91
void evergreen_init_vtbl(radeonContextPtr radeon)
93
radeon->vtbl.get_lock = evergreen_get_lock;
94
radeon->vtbl.update_viewport_offset = evergreenUpdateViewportOffset;
95
radeon->vtbl.emit_cs_header = evergreen_vtbl_emit_cs_header;
96
radeon->vtbl.swtcl_flush = NULL;
97
radeon->vtbl.pre_emit_atoms = evergreen_vtbl_pre_emit_atoms;
98
radeon->vtbl.fallback = evergreen_fallback;
99
radeon->vtbl.emit_query_finish = evergreen_emit_query_finish;
100
radeon->vtbl.check_blit = evergreen_check_blit;
101
radeon->vtbl.blit = evergreen_blit;
102
radeon->vtbl.is_format_renderable = r600IsFormatRenderable;