1 /****************************************************************************
3 * Copyright (C) 2005 - 2014 by Vivante Corp.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the license, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *****************************************************************************/
22 #ifndef __gc_hal_kernel_context_h_
23 #define __gc_hal_kernel_context_h_
25 #include "gc_hal_kernel_buffer.h"
27 /* Exprimental optimization. */
28 #define REMOVE_DUPLICATED_COPY_FROM_USER 1
34 /* Maps state locations within the context buffer. */
35 typedef struct _gcsSTATE_MAP * gcsSTATE_MAP_PTR;
36 typedef struct _gcsSTATE_MAP
38 /* Index of the state in the context buffer. */
47 typedef struct _gcsCONTEXT * gcsCONTEXT_PTR;
48 typedef struct _gcsCONTEXT
50 /* For debugging: the number of context buffer in the order of creation. */
51 #if gcmIS_DEBUG(gcdDEBUG_CODE)
55 /* Pointer to gckEVENT object. */
58 /* Context busy signal. */
61 /* Physical address of the context buffer. */
62 gctPHYS_ADDR physical;
64 /* Logical address of the context buffer. */
65 gctUINT32_PTR logical;
67 /* Hardware address of the context buffer. */
70 /* Pointer to the LINK commands. */
74 /* The number of pending state deltas. */
77 /* Pointer to the first delta to be applied. */
78 gcsSTATE_DELTA_PTR delta;
80 /* Next context buffer. */
85 typedef struct _gcsRECORD_ARRAY_MAP * gcsRECORD_ARRAY_MAP_PTR;
86 struct _gcsRECORD_ARRAY_MAP
88 /* User pointer key. */
91 /* Kernel memory buffer. */
92 gcsSTATE_DELTA_RECORD_PTR kData;
95 gcsRECORD_ARRAY_MAP_PTR next;
99 /* gckCONTEXT structure that hold the current context. */
105 /* Pointer to gckOS object. */
108 /* Pointer to gckHARDWARE object. */
109 gckHARDWARE hardware;
111 /* Command buffer alignment. */
113 gctUINT32 reservedHead;
114 gctUINT32 reservedTail;
116 /* Context buffer metrics. */
117 gctSIZE_T stateCount;
119 gctUINT32 bufferSize;
120 gctUINT32 linkIndex2D;
121 gctUINT32 linkIndex3D;
122 gctUINT32 linkIndexXD;
123 gctUINT32 entryOffset3D;
124 gctUINT32 entryOffsetXDFrom2D;
125 gctUINT32 entryOffsetXDFrom3D;
131 gcsCONTEXT_PTR dirtyBuffer;
134 gcsSTATE_MAP_PTR map;
136 /* List of context buffers. */
137 gcsCONTEXT_PTR buffer;
139 /* A copy of the user record array. */
140 gctUINT recordArraySize;
141 #if REMOVE_DUPLICATED_COPY_FROM_USER
142 gcsRECORD_ARRAY_MAP_PTR recordArrayMap;
144 gcsSTATE_DELTA_RECORD_PTR recordArray;
147 /* Requested pipe select for context. */
148 gcePIPE_SELECT entryPipe;
149 gcePIPE_SELECT exitPipe;
151 /* Variables used for building state buffer. */
152 gctUINT32 lastAddress;
157 gctUINT32 pipeSelectBytes;
164 #if VIVANTE_PROFILER_CONTEXT
165 gcsPROFILER_COUNTERS latestProfiler;
166 gcsPROFILER_COUNTERS histroyProfiler;
167 gctUINT32 prevVSInstCount;
168 gctUINT32 prevVSBranchInstCount;
169 gctUINT32 prevVSTexInstCount;
170 gctUINT32 prevVSVertexCount;
171 gctUINT32 prevPSInstCount;
172 gctUINT32 prevPSBranchInstCount;
173 gctUINT32 prevPSTexInstCount;
174 gctUINT32 prevPSPixelCount;
182 #endif /* __gc_hal_kernel_context_h_ */