1d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson/**************************************************************************
2d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson *
3d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson * Copyright 2009 VMware, Inc.
4d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson * All Rights Reserved.
5d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson *
6d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson * Permission is hereby granted, free of charge, to any person obtaining a
7d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson * copy of this software and associated documentation files (the
8d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson * "Software"), to deal in the Software without restriction, including
9d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson * without limitation the rights to use, copy, modify, merge, publish,
10d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson * distribute, sub license, and/or sell copies of the Software, and to
11d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson * permit persons to whom the Software is furnished to do so, subject to
12d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson * the following conditions:
13d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson *
14d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson * The above copyright notice and this permission notice (including the
15d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson * next paragraph) shall be included in all copies or substantial portions
16d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson * of the Software.
17d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson *
18d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson *
26d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson **************************************************************************/
27d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
28d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
29d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson#include "pipe/p_context.h"
303f758d4ed42f6b4c6bed60f8270ef908d3829ee5Corbin Simpson
313f758d4ed42f6b4c6bed60f8270ef908d3829ee5Corbin Simpson#include "util/u_format.h"
32d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson#include "util/u_memory.h"
33d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson#include "util/u_inlines.h"
34d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
35d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson#include "glhd_context.h"
36d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson#include "glhd_objects.h"
37d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
38d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
39d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpsonstatic void
405b45775e415dac526a5729d7f4d99a1718206f09José Fonsecagalahad_context_destroy(struct pipe_context *_pipe)
41d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson{
42d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct galahad_context *glhd_pipe = galahad_context(_pipe);
43d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct pipe_context *pipe = glhd_pipe->pipe;
44d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
45d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   pipe->destroy(pipe);
46d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
47d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   FREE(glhd_pipe);
48d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson}
49d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
50d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpsonstatic void
515b45775e415dac526a5729d7f4d99a1718206f09José Fonsecagalahad_context_draw_vbo(struct pipe_context *_pipe,
526d28bf917fb1d741d90fd3f05c22769376021fcaChia-I Wu                 const struct pipe_draw_info *info)
536d28bf917fb1d741d90fd3f05c22769376021fcaChia-I Wu{
546d28bf917fb1d741d90fd3f05c22769376021fcaChia-I Wu   struct galahad_context *glhd_pipe = galahad_context(_pipe);
556d28bf917fb1d741d90fd3f05c22769376021fcaChia-I Wu   struct pipe_context *pipe = glhd_pipe->pipe;
566d28bf917fb1d741d90fd3f05c22769376021fcaChia-I Wu
573b8182793b4f7d87ba274de152fb106996e75098Brian Paul   /* XXX we should check that all bound resources are unmapped
583b8182793b4f7d87ba274de152fb106996e75098Brian Paul    * before drawing.
593b8182793b4f7d87ba274de152fb106996e75098Brian Paul    */
603b8182793b4f7d87ba274de152fb106996e75098Brian Paul
616d28bf917fb1d741d90fd3f05c22769376021fcaChia-I Wu   pipe->draw_vbo(pipe, info);
626d28bf917fb1d741d90fd3f05c22769376021fcaChia-I Wu}
636d28bf917fb1d741d90fd3f05c22769376021fcaChia-I Wu
64d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpsonstatic struct pipe_query *
655b45775e415dac526a5729d7f4d99a1718206f09José Fonsecagalahad_context_create_query(struct pipe_context *_pipe,
66d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                      unsigned query_type)
67d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson{
68d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct galahad_context *glhd_pipe = galahad_context(_pipe);
69d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct pipe_context *pipe = glhd_pipe->pipe;
70d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
71a6cc91487446f8e1e72e4f67823a359c0b3a41d6Corbin Simpson   if (query_type == PIPE_QUERY_OCCLUSION_COUNTER &&
72a6cc91487446f8e1e72e4f67823a359c0b3a41d6Corbin Simpson      !pipe->screen->get_param(pipe->screen, PIPE_CAP_OCCLUSION_QUERY)) {
73a6cc91487446f8e1e72e4f67823a359c0b3a41d6Corbin Simpson      glhd_error("Occlusion query requested but not supported");
74a6cc91487446f8e1e72e4f67823a359c0b3a41d6Corbin Simpson   }
75a6cc91487446f8e1e72e4f67823a359c0b3a41d6Corbin Simpson
76a6cc91487446f8e1e72e4f67823a359c0b3a41d6Corbin Simpson   if (query_type == PIPE_QUERY_TIME_ELAPSED &&
77a6cc91487446f8e1e72e4f67823a359c0b3a41d6Corbin Simpson      !pipe->screen->get_param(pipe->screen, PIPE_CAP_TIMER_QUERY)) {
78a6cc91487446f8e1e72e4f67823a359c0b3a41d6Corbin Simpson      glhd_error("Timer query requested but not supported");
79a6cc91487446f8e1e72e4f67823a359c0b3a41d6Corbin Simpson   }
80a6cc91487446f8e1e72e4f67823a359c0b3a41d6Corbin Simpson
81d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   return pipe->create_query(pipe,
82d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                             query_type);
83d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson}
84d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
85d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpsonstatic void
865b45775e415dac526a5729d7f4d99a1718206f09José Fonsecagalahad_context_destroy_query(struct pipe_context *_pipe,
87d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                       struct pipe_query *query)
88d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson{
89d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct galahad_context *glhd_pipe = galahad_context(_pipe);
90d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct pipe_context *pipe = glhd_pipe->pipe;
91d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
92d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   pipe->destroy_query(pipe,
93d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                       query);
94d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson}
95d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
96d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpsonstatic void
975b45775e415dac526a5729d7f4d99a1718206f09José Fonsecagalahad_context_begin_query(struct pipe_context *_pipe,
98d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                     struct pipe_query *query)
99d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson{
100d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct galahad_context *glhd_pipe = galahad_context(_pipe);
101d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct pipe_context *pipe = glhd_pipe->pipe;
102d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
103d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   pipe->begin_query(pipe,
104d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                     query);
105d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson}
106d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
107d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpsonstatic void
1085b45775e415dac526a5729d7f4d99a1718206f09José Fonsecagalahad_context_end_query(struct pipe_context *_pipe,
109d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                   struct pipe_query *query)
110d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson{
111d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct galahad_context *glhd_pipe = galahad_context(_pipe);
112d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct pipe_context *pipe = glhd_pipe->pipe;
113d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
114d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   pipe->end_query(pipe,
115d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                   query);
116d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson}
117d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
118d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpsonstatic boolean
1195b45775e415dac526a5729d7f4d99a1718206f09José Fonsecagalahad_context_get_query_result(struct pipe_context *_pipe,
120d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                          struct pipe_query *query,
121d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                          boolean wait,
1224445e170bee23a3607ece0e010adef7058ac6a11Marek Olšák                          union pipe_query_result *result)
123d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson{
124d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct galahad_context *glhd_pipe = galahad_context(_pipe);
125d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct pipe_context *pipe = glhd_pipe->pipe;
126d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
127d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   return pipe->get_query_result(pipe,
128d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                                 query,
129d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                                 wait,
130d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                                 result);
131d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson}
132d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
133d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpsonstatic void *
1345b45775e415dac526a5729d7f4d99a1718206f09José Fonsecagalahad_context_create_blend_state(struct pipe_context *_pipe,
135d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                            const struct pipe_blend_state *blend)
136d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson{
137d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct galahad_context *glhd_pipe = galahad_context(_pipe);
138d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct pipe_context *pipe = glhd_pipe->pipe;
139d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
140484bb0ea58aae909c3f0accf9b085ac0a5861fe2Corbin Simpson   if (blend->logicop_enable) {
141484bb0ea58aae909c3f0accf9b085ac0a5861fe2Corbin Simpson      if (blend->rt[0].blend_enable) {
142484bb0ea58aae909c3f0accf9b085ac0a5861fe2Corbin Simpson         glhd_warn("Blending enabled for render target 0, but logicops "
143484bb0ea58aae909c3f0accf9b085ac0a5861fe2Corbin Simpson            "are enabled");
144484bb0ea58aae909c3f0accf9b085ac0a5861fe2Corbin Simpson      }
145484bb0ea58aae909c3f0accf9b085ac0a5861fe2Corbin Simpson   }
146484bb0ea58aae909c3f0accf9b085ac0a5861fe2Corbin Simpson
147d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   return pipe->create_blend_state(pipe,
148d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                                   blend);
149d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson}
150d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
151d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpsonstatic void
1525b45775e415dac526a5729d7f4d99a1718206f09José Fonsecagalahad_context_bind_blend_state(struct pipe_context *_pipe,
153d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                          void *blend)
154d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson{
155d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct galahad_context *glhd_pipe = galahad_context(_pipe);
156d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct pipe_context *pipe = glhd_pipe->pipe;
157d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
158d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   pipe->bind_blend_state(pipe,
159d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                              blend);
160d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson}
161d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
162d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpsonstatic void
1635b45775e415dac526a5729d7f4d99a1718206f09José Fonsecagalahad_context_delete_blend_state(struct pipe_context *_pipe,
164d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                            void *blend)
165d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson{
166d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct galahad_context *glhd_pipe = galahad_context(_pipe);
167d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct pipe_context *pipe = glhd_pipe->pipe;
168d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
169d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   pipe->delete_blend_state(pipe,
170d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                            blend);
171d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson}
172d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
173d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpsonstatic void *
1745b45775e415dac526a5729d7f4d99a1718206f09José Fonsecagalahad_context_create_sampler_state(struct pipe_context *_pipe,
175d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                              const struct pipe_sampler_state *sampler)
176d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson{
177d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct galahad_context *glhd_pipe = galahad_context(_pipe);
178d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct pipe_context *pipe = glhd_pipe->pipe;
179d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
180d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   return pipe->create_sampler_state(pipe,
181d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                                     sampler);
182d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson}
183d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
184d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpsonstatic void
185f3cc4990a090ee076d8217c83aaf16e036e66686Brian Paulgalahad_context_bind_sampler_states(struct pipe_context *_pipe,
186f3cc4990a090ee076d8217c83aaf16e036e66686Brian Paul                                    unsigned shader,
187f3cc4990a090ee076d8217c83aaf16e036e66686Brian Paul                                    unsigned start,
188f3cc4990a090ee076d8217c83aaf16e036e66686Brian Paul                                    unsigned num_samplers,
189f3cc4990a090ee076d8217c83aaf16e036e66686Brian Paul                                    void **samplers)
190d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson{
191d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct galahad_context *glhd_pipe = galahad_context(_pipe);
192d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct pipe_context *pipe = glhd_pipe->pipe;
193d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
194cdc1c67b9896cd0d919f736fe61a4396bf0ad5c0Corbin Simpson   if (num_samplers > PIPE_MAX_SAMPLERS) {
195f3cc4990a090ee076d8217c83aaf16e036e66686Brian Paul      glhd_error("%u samplers requested, "
196cdc1c67b9896cd0d919f736fe61a4396bf0ad5c0Corbin Simpson         "but only %u are permitted by API",
197cdc1c67b9896cd0d919f736fe61a4396bf0ad5c0Corbin Simpson         num_samplers, PIPE_MAX_SAMPLERS);
198cdc1c67b9896cd0d919f736fe61a4396bf0ad5c0Corbin Simpson   }
199cdc1c67b9896cd0d919f736fe61a4396bf0ad5c0Corbin Simpson
200f3cc4990a090ee076d8217c83aaf16e036e66686Brian Paul   switch (shader) {
201f3cc4990a090ee076d8217c83aaf16e036e66686Brian Paul   case PIPE_SHADER_VERTEX:
202f3cc4990a090ee076d8217c83aaf16e036e66686Brian Paul      pipe->bind_vertex_sampler_states(pipe, num_samplers, samplers);
203f3cc4990a090ee076d8217c83aaf16e036e66686Brian Paul      break;
204f3cc4990a090ee076d8217c83aaf16e036e66686Brian Paul   case PIPE_SHADER_FRAGMENT:
205f3cc4990a090ee076d8217c83aaf16e036e66686Brian Paul      pipe->bind_fragment_sampler_states(pipe, num_samplers, samplers);
206f3cc4990a090ee076d8217c83aaf16e036e66686Brian Paul      break;
207f3cc4990a090ee076d8217c83aaf16e036e66686Brian Paul   default:
208f3cc4990a090ee076d8217c83aaf16e036e66686Brian Paul      assert(0);
209f3cc4990a090ee076d8217c83aaf16e036e66686Brian Paul   }
210d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson}
211d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
212d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpsonstatic void
2135b45775e415dac526a5729d7f4d99a1718206f09José Fonsecagalahad_context_bind_vertex_sampler_states(struct pipe_context *_pipe,
214f3cc4990a090ee076d8217c83aaf16e036e66686Brian Paul                                           unsigned num_samplers,
215f3cc4990a090ee076d8217c83aaf16e036e66686Brian Paul                                           void **samplers)
216d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson{
217f3cc4990a090ee076d8217c83aaf16e036e66686Brian Paul   galahad_context_bind_sampler_states(_pipe, PIPE_SHADER_VERTEX,
218f3cc4990a090ee076d8217c83aaf16e036e66686Brian Paul                                       0, num_samplers, samplers);
219f3cc4990a090ee076d8217c83aaf16e036e66686Brian Paul}
220cdc1c67b9896cd0d919f736fe61a4396bf0ad5c0Corbin Simpson
221f3cc4990a090ee076d8217c83aaf16e036e66686Brian Paulstatic void
222f3cc4990a090ee076d8217c83aaf16e036e66686Brian Paulgalahad_context_bind_fragment_sampler_states(struct pipe_context *_pipe,
223f3cc4990a090ee076d8217c83aaf16e036e66686Brian Paul                                             unsigned num_samplers,
224f3cc4990a090ee076d8217c83aaf16e036e66686Brian Paul                                             void **samplers)
225f3cc4990a090ee076d8217c83aaf16e036e66686Brian Paul{
226f3cc4990a090ee076d8217c83aaf16e036e66686Brian Paul   galahad_context_bind_sampler_states(_pipe, PIPE_SHADER_FRAGMENT,
227f3cc4990a090ee076d8217c83aaf16e036e66686Brian Paul                                       0, num_samplers, samplers);
228d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson}
229d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
230f3cc4990a090ee076d8217c83aaf16e036e66686Brian Paul
231d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpsonstatic void
2325b45775e415dac526a5729d7f4d99a1718206f09José Fonsecagalahad_context_delete_sampler_state(struct pipe_context *_pipe,
233d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                              void *sampler)
234d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson{
235d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct galahad_context *glhd_pipe = galahad_context(_pipe);
236d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct pipe_context *pipe = glhd_pipe->pipe;
237d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
238d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   pipe->delete_sampler_state(pipe,
239d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                              sampler);
240d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson}
241d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
242d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpsonstatic void *
2435b45775e415dac526a5729d7f4d99a1718206f09José Fonsecagalahad_context_create_rasterizer_state(struct pipe_context *_pipe,
244d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                                 const struct pipe_rasterizer_state *rasterizer)
245d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson{
246d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct galahad_context *glhd_pipe = galahad_context(_pipe);
247d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct pipe_context *pipe = glhd_pipe->pipe;
248d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
249e6ee4e1bdf0f82fd3c09a0cb95a5844bed25a1d1Corbin Simpson   if (rasterizer->point_quad_rasterization) {
250e6ee4e1bdf0f82fd3c09a0cb95a5844bed25a1d1Corbin Simpson       if (rasterizer->point_smooth) {
251e6ee4e1bdf0f82fd3c09a0cb95a5844bed25a1d1Corbin Simpson           glhd_warn("Point smoothing requested but ignored");
252e6ee4e1bdf0f82fd3c09a0cb95a5844bed25a1d1Corbin Simpson       }
253e6ee4e1bdf0f82fd3c09a0cb95a5844bed25a1d1Corbin Simpson   } else {
254e6ee4e1bdf0f82fd3c09a0cb95a5844bed25a1d1Corbin Simpson       if (rasterizer->sprite_coord_enable) {
255e6ee4e1bdf0f82fd3c09a0cb95a5844bed25a1d1Corbin Simpson           glhd_warn("Point sprites requested but ignored");
256e6ee4e1bdf0f82fd3c09a0cb95a5844bed25a1d1Corbin Simpson       }
257e6ee4e1bdf0f82fd3c09a0cb95a5844bed25a1d1Corbin Simpson   }
258e6ee4e1bdf0f82fd3c09a0cb95a5844bed25a1d1Corbin Simpson
259d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   return pipe->create_rasterizer_state(pipe,
260d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                                        rasterizer);
261d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson}
262d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
263d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpsonstatic void
2645b45775e415dac526a5729d7f4d99a1718206f09José Fonsecagalahad_context_bind_rasterizer_state(struct pipe_context *_pipe,
265d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                               void *rasterizer)
266d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson{
267d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct galahad_context *glhd_pipe = galahad_context(_pipe);
268d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct pipe_context *pipe = glhd_pipe->pipe;
269d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
270d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   pipe->bind_rasterizer_state(pipe,
271d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                               rasterizer);
272d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson}
273d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
274d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpsonstatic void
2755b45775e415dac526a5729d7f4d99a1718206f09José Fonsecagalahad_context_delete_rasterizer_state(struct pipe_context *_pipe,
276d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                                 void *rasterizer)
277d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson{
278d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct galahad_context *glhd_pipe = galahad_context(_pipe);
279d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct pipe_context *pipe = glhd_pipe->pipe;
280d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
281d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   pipe->delete_rasterizer_state(pipe,
282d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                                 rasterizer);
283d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson}
284d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
285d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpsonstatic void *
2865b45775e415dac526a5729d7f4d99a1718206f09José Fonsecagalahad_context_create_depth_stencil_alpha_state(struct pipe_context *_pipe,
287d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                                          const struct pipe_depth_stencil_alpha_state *depth_stencil_alpha)
288d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson{
289d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct galahad_context *glhd_pipe = galahad_context(_pipe);
290d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct pipe_context *pipe = glhd_pipe->pipe;
291d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
292d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   return pipe->create_depth_stencil_alpha_state(pipe,
293d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                                                 depth_stencil_alpha);
294d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson}
295d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
296d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpsonstatic void
2975b45775e415dac526a5729d7f4d99a1718206f09José Fonsecagalahad_context_bind_depth_stencil_alpha_state(struct pipe_context *_pipe,
298d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                                        void *depth_stencil_alpha)
299d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson{
300d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct galahad_context *glhd_pipe = galahad_context(_pipe);
301d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct pipe_context *pipe = glhd_pipe->pipe;
302d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
303d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   pipe->bind_depth_stencil_alpha_state(pipe,
304d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                                        depth_stencil_alpha);
305d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson}
306d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
307d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpsonstatic void
3085b45775e415dac526a5729d7f4d99a1718206f09José Fonsecagalahad_context_delete_depth_stencil_alpha_state(struct pipe_context *_pipe,
309d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                                          void *depth_stencil_alpha)
310d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson{
311d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct galahad_context *glhd_pipe = galahad_context(_pipe);
312d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct pipe_context *pipe = glhd_pipe->pipe;
313d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
314d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   pipe->delete_depth_stencil_alpha_state(pipe,
315d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                                          depth_stencil_alpha);
316d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson}
317d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
318d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpsonstatic void *
3195b45775e415dac526a5729d7f4d99a1718206f09José Fonsecagalahad_context_create_fs_state(struct pipe_context *_pipe,
320d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                         const struct pipe_shader_state *fs)
321d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson{
322d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct galahad_context *glhd_pipe = galahad_context(_pipe);
323d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct pipe_context *pipe = glhd_pipe->pipe;
324d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
325d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   return pipe->create_fs_state(pipe,
326d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                                fs);
327d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson}
328d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
329d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpsonstatic void
3305b45775e415dac526a5729d7f4d99a1718206f09José Fonsecagalahad_context_bind_fs_state(struct pipe_context *_pipe,
331d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                       void *fs)
332d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson{
333d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct galahad_context *glhd_pipe = galahad_context(_pipe);
334d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct pipe_context *pipe = glhd_pipe->pipe;
335d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
336d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   pipe->bind_fs_state(pipe,
337d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                       fs);
338d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson}
339d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
340d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpsonstatic void
3415b45775e415dac526a5729d7f4d99a1718206f09José Fonsecagalahad_context_delete_fs_state(struct pipe_context *_pipe,
342d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                         void *fs)
343d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson{
344d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct galahad_context *glhd_pipe = galahad_context(_pipe);
345d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct pipe_context *pipe = glhd_pipe->pipe;
346d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
347d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   pipe->delete_fs_state(pipe,
348d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                         fs);
349d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson}
350d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
351d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpsonstatic void *
3525b45775e415dac526a5729d7f4d99a1718206f09José Fonsecagalahad_context_create_vs_state(struct pipe_context *_pipe,
353d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                         const struct pipe_shader_state *vs)
354d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson{
355d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct galahad_context *glhd_pipe = galahad_context(_pipe);
356d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct pipe_context *pipe = glhd_pipe->pipe;
357d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
358d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   return pipe->create_vs_state(pipe,
359d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                                vs);
360d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson}
361d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
362d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpsonstatic void
3635b45775e415dac526a5729d7f4d99a1718206f09José Fonsecagalahad_context_bind_vs_state(struct pipe_context *_pipe,
364d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                       void *vs)
365d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson{
366d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct galahad_context *glhd_pipe = galahad_context(_pipe);
367d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct pipe_context *pipe = glhd_pipe->pipe;
368d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
369d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   pipe->bind_vs_state(pipe,
370d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                       vs);
371d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson}
372d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
373d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpsonstatic void
3745b45775e415dac526a5729d7f4d99a1718206f09José Fonsecagalahad_context_delete_vs_state(struct pipe_context *_pipe,
375d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                         void *vs)
376d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson{
377d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct galahad_context *glhd_pipe = galahad_context(_pipe);
378d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct pipe_context *pipe = glhd_pipe->pipe;
379d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
380d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   pipe->delete_vs_state(pipe,
381d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                         vs);
382d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson}
383d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
384d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
385d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpsonstatic void *
3865b45775e415dac526a5729d7f4d99a1718206f09José Fonsecagalahad_context_create_vertex_elements_state(struct pipe_context *_pipe,
387d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                                      unsigned num_elements,
388d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                                      const struct pipe_vertex_element *vertex_elements)
389d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson{
390d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct galahad_context *glhd_pipe = galahad_context(_pipe);
391d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct pipe_context *pipe = glhd_pipe->pipe;
392d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
39323aa3c552cc54a3242142b82916090f8b7b32e44Jakob Bornecrantz   /* XXX check if stride lines up with element size, at least for floats */
39423aa3c552cc54a3242142b82916090f8b7b32e44Jakob Bornecrantz
395d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   return pipe->create_vertex_elements_state(pipe,
396d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                                             num_elements,
397d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                                             vertex_elements);
398d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson}
399d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
400d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpsonstatic void
4015b45775e415dac526a5729d7f4d99a1718206f09José Fonsecagalahad_context_bind_vertex_elements_state(struct pipe_context *_pipe,
402d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                                    void *velems)
403d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson{
404d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct galahad_context *glhd_pipe = galahad_context(_pipe);
405d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct pipe_context *pipe = glhd_pipe->pipe;
406d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
407d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   pipe->bind_vertex_elements_state(pipe,
408d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                                    velems);
409d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson}
410d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
411d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpsonstatic void
4125b45775e415dac526a5729d7f4d99a1718206f09José Fonsecagalahad_context_delete_vertex_elements_state(struct pipe_context *_pipe,
413d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                                      void *velems)
414d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson{
415d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct galahad_context *glhd_pipe = galahad_context(_pipe);
416d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct pipe_context *pipe = glhd_pipe->pipe;
417d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
418d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   pipe->delete_vertex_elements_state(pipe,
419d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                                      velems);
420d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson}
421d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
422d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpsonstatic void
4235b45775e415dac526a5729d7f4d99a1718206f09José Fonsecagalahad_context_set_blend_color(struct pipe_context *_pipe,
424d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                         const struct pipe_blend_color *blend_color)
425d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson{
426d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct galahad_context *glhd_pipe = galahad_context(_pipe);
427d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct pipe_context *pipe = glhd_pipe->pipe;
428d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
429d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   pipe->set_blend_color(pipe,
430d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                         blend_color);
431d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson}
432d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
433d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpsonstatic void
4345b45775e415dac526a5729d7f4d99a1718206f09José Fonsecagalahad_context_set_stencil_ref(struct pipe_context *_pipe,
435d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                         const struct pipe_stencil_ref *stencil_ref)
436d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson{
437d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct galahad_context *glhd_pipe = galahad_context(_pipe);
438d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct pipe_context *pipe = glhd_pipe->pipe;
439d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
440d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   pipe->set_stencil_ref(pipe,
441d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                         stencil_ref);
442d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson}
443d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
444d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpsonstatic void
4455b45775e415dac526a5729d7f4d99a1718206f09José Fonsecagalahad_context_set_clip_state(struct pipe_context *_pipe,
446d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                        const struct pipe_clip_state *clip)
447d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson{
448d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct galahad_context *glhd_pipe = galahad_context(_pipe);
449d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct pipe_context *pipe = glhd_pipe->pipe;
450d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
451d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   pipe->set_clip_state(pipe,
452d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                        clip);
453d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson}
454d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
455d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpsonstatic void
4565b45775e415dac526a5729d7f4d99a1718206f09José Fonsecagalahad_context_set_sample_mask(struct pipe_context *_pipe,
457d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                         unsigned sample_mask)
458d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson{
459d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct galahad_context *glhd_pipe = galahad_context(_pipe);
460d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct pipe_context *pipe = glhd_pipe->pipe;
461d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
462d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   pipe->set_sample_mask(pipe,
463d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                         sample_mask);
464d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson}
465d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
466d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpsonstatic void
4675b45775e415dac526a5729d7f4d99a1718206f09José Fonsecagalahad_context_set_constant_buffer(struct pipe_context *_pipe,
468d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                             uint shader,
469d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                             uint index,
470507337864fa80caf9f26602324d2c28dd0a75d61Marek Olšák                             struct pipe_constant_buffer *_cb)
471d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson{
472d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct galahad_context *glhd_pipe = galahad_context(_pipe);
473d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct pipe_context *pipe = glhd_pipe->pipe;
474507337864fa80caf9f26602324d2c28dd0a75d61Marek Olšák   struct pipe_constant_buffer cb;
475d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
476cdc1c67b9896cd0d919f736fe61a4396bf0ad5c0Corbin Simpson   if (shader >= PIPE_SHADER_TYPES) {
477cdc1c67b9896cd0d919f736fe61a4396bf0ad5c0Corbin Simpson      glhd_error("Unknown shader type %u", shader);
478cdc1c67b9896cd0d919f736fe61a4396bf0ad5c0Corbin Simpson   }
479cdc1c67b9896cd0d919f736fe61a4396bf0ad5c0Corbin Simpson
480e0ef4800f5deb81ed57dccf8ba39e01c12f4beffCorbin Simpson   if (index &&
481e0ef4800f5deb81ed57dccf8ba39e01c12f4beffCorbin Simpson      index >=
482a508d2dddcc67d0f92cc36b9ed6f36a9bbfc579dLuca Barbieri         pipe->screen->get_shader_param(pipe->screen, shader, PIPE_SHADER_CAP_MAX_CONST_BUFFERS)) {
483e0ef4800f5deb81ed57dccf8ba39e01c12f4beffCorbin Simpson      glhd_error("Access to constant buffer %u requested, "
484e0ef4800f5deb81ed57dccf8ba39e01c12f4beffCorbin Simpson         "but only %d are supported",
485e0ef4800f5deb81ed57dccf8ba39e01c12f4beffCorbin Simpson         index,
486a508d2dddcc67d0f92cc36b9ed6f36a9bbfc579dLuca Barbieri         pipe->screen->get_shader_param(pipe->screen, shader, PIPE_SHADER_CAP_MAX_CONST_BUFFERS));
487e0ef4800f5deb81ed57dccf8ba39e01c12f4beffCorbin Simpson   }
488e0ef4800f5deb81ed57dccf8ba39e01c12f4beffCorbin Simpson
489d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   /* XXX hmm? unwrap the input state */
490507337864fa80caf9f26602324d2c28dd0a75d61Marek Olšák   if (_cb) {
491507337864fa80caf9f26602324d2c28dd0a75d61Marek Olšák      cb = *_cb;
492507337864fa80caf9f26602324d2c28dd0a75d61Marek Olšák      cb.buffer = galahad_resource_unwrap(_cb->buffer);
493d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   }
494d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
495d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   pipe->set_constant_buffer(pipe,
496d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                             shader,
497d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                             index,
498507337864fa80caf9f26602324d2c28dd0a75d61Marek Olšák                             _cb ? &cb : NULL);
499d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson}
500d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
501d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpsonstatic void
5025b45775e415dac526a5729d7f4d99a1718206f09José Fonsecagalahad_context_set_framebuffer_state(struct pipe_context *_pipe,
503d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                               const struct pipe_framebuffer_state *_state)
504d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson{
505d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct galahad_context *glhd_pipe = galahad_context(_pipe);
506d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct pipe_context *pipe = glhd_pipe->pipe;
507d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct pipe_framebuffer_state unwrapped_state;
508d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct pipe_framebuffer_state *state = NULL;
509d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   unsigned i;
510d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
511aa451d509df844e4652853f08e31bc1ee18c04acCorbin Simpson   if (_state->nr_cbufs > PIPE_MAX_COLOR_BUFS) {
512aa451d509df844e4652853f08e31bc1ee18c04acCorbin Simpson      glhd_error("%d render targets bound, but only %d are permitted by API",
513aa451d509df844e4652853f08e31bc1ee18c04acCorbin Simpson         _state->nr_cbufs, PIPE_MAX_COLOR_BUFS);
514aa451d509df844e4652853f08e31bc1ee18c04acCorbin Simpson   } else if (_state->nr_cbufs >
515aa451d509df844e4652853f08e31bc1ee18c04acCorbin Simpson      pipe->screen->get_param(pipe->screen, PIPE_CAP_MAX_RENDER_TARGETS)) {
516aa451d509df844e4652853f08e31bc1ee18c04acCorbin Simpson      glhd_warn("%d render targets bound, but only %d are supported",
517aa451d509df844e4652853f08e31bc1ee18c04acCorbin Simpson         _state->nr_cbufs,
518aa451d509df844e4652853f08e31bc1ee18c04acCorbin Simpson         pipe->screen->get_param(pipe->screen, PIPE_CAP_MAX_RENDER_TARGETS));
519aa451d509df844e4652853f08e31bc1ee18c04acCorbin Simpson   }
520aa451d509df844e4652853f08e31bc1ee18c04acCorbin Simpson
521d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   /* unwrap the input state */
522d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   if (_state) {
523d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson      memcpy(&unwrapped_state, _state, sizeof(unwrapped_state));
524d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson      for(i = 0; i < _state->nr_cbufs; i++)
525d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson         unwrapped_state.cbufs[i] = galahad_surface_unwrap(_state->cbufs[i]);
526d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson      for (; i < PIPE_MAX_COLOR_BUFS; i++)
527d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson         unwrapped_state.cbufs[i] = NULL;
528d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson      unwrapped_state.zsbuf = galahad_surface_unwrap(_state->zsbuf);
529d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson      state = &unwrapped_state;
530d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   }
531d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
532d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   pipe->set_framebuffer_state(pipe,
533d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                               state);
534d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson}
535d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
536d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpsonstatic void
5375b45775e415dac526a5729d7f4d99a1718206f09José Fonsecagalahad_context_set_polygon_stipple(struct pipe_context *_pipe,
538d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                             const struct pipe_poly_stipple *poly_stipple)
539d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson{
540d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct galahad_context *glhd_pipe = galahad_context(_pipe);
541d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct pipe_context *pipe = glhd_pipe->pipe;
542d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
543d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   pipe->set_polygon_stipple(pipe,
544d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                             poly_stipple);
545d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson}
546d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
547d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpsonstatic void
5485b45775e415dac526a5729d7f4d99a1718206f09José Fonsecagalahad_context_set_scissor_state(struct pipe_context *_pipe,
549d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                           const struct pipe_scissor_state *scissor)
550d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson{
551d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct galahad_context *glhd_pipe = galahad_context(_pipe);
552d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct pipe_context *pipe = glhd_pipe->pipe;
553d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
554d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   pipe->set_scissor_state(pipe,
555d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                           scissor);
556d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson}
557d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
558d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpsonstatic void
5595b45775e415dac526a5729d7f4d99a1718206f09José Fonsecagalahad_context_set_viewport_state(struct pipe_context *_pipe,
560d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                            const struct pipe_viewport_state *viewport)
561d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson{
562d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct galahad_context *glhd_pipe = galahad_context(_pipe);
563d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct pipe_context *pipe = glhd_pipe->pipe;
564d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
565d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   pipe->set_viewport_state(pipe,
566d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                            viewport);
567d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson}
568d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
569d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpsonstatic void
570f3cc4990a090ee076d8217c83aaf16e036e66686Brian Paulgalahad_context_set_sampler_views(struct pipe_context *_pipe,
571f3cc4990a090ee076d8217c83aaf16e036e66686Brian Paul                                  unsigned shader,
572f3cc4990a090ee076d8217c83aaf16e036e66686Brian Paul                                  unsigned start,
573f3cc4990a090ee076d8217c83aaf16e036e66686Brian Paul                                  unsigned num,
574f3cc4990a090ee076d8217c83aaf16e036e66686Brian Paul                                  struct pipe_sampler_view **_views)
575d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson{
576d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct galahad_context *glhd_pipe = galahad_context(_pipe);
577d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct pipe_context *pipe = glhd_pipe->pipe;
578d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct pipe_sampler_view *unwrapped_views[PIPE_MAX_SAMPLERS];
579d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct pipe_sampler_view **views = NULL;
580d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   unsigned i;
581d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
582d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   if (_views) {
583d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson      for (i = 0; i < num; i++)
584d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson         unwrapped_views[i] = galahad_sampler_view_unwrap(_views[i]);
585d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson      for (; i < PIPE_MAX_SAMPLERS; i++)
586d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson         unwrapped_views[i] = NULL;
587d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
588d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson      views = unwrapped_views;
589d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   }
590d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
591f3cc4990a090ee076d8217c83aaf16e036e66686Brian Paul   switch (shader) {
592f3cc4990a090ee076d8217c83aaf16e036e66686Brian Paul   case PIPE_SHADER_VERTEX:
593f3cc4990a090ee076d8217c83aaf16e036e66686Brian Paul      pipe->set_vertex_sampler_views(pipe, num, views);
594f3cc4990a090ee076d8217c83aaf16e036e66686Brian Paul      break;
595f3cc4990a090ee076d8217c83aaf16e036e66686Brian Paul   case PIPE_SHADER_FRAGMENT:
596f3cc4990a090ee076d8217c83aaf16e036e66686Brian Paul      pipe->set_fragment_sampler_views(pipe, num, views);
597f3cc4990a090ee076d8217c83aaf16e036e66686Brian Paul      break;
598f3cc4990a090ee076d8217c83aaf16e036e66686Brian Paul   default:
599f3cc4990a090ee076d8217c83aaf16e036e66686Brian Paul      assert(0);
600f3cc4990a090ee076d8217c83aaf16e036e66686Brian Paul   }
601d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson}
602d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
603d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpsonstatic void
6045b45775e415dac526a5729d7f4d99a1718206f09José Fonsecagalahad_context_set_vertex_sampler_views(struct pipe_context *_pipe,
605f3cc4990a090ee076d8217c83aaf16e036e66686Brian Paul                                         unsigned num,
606f3cc4990a090ee076d8217c83aaf16e036e66686Brian Paul                                         struct pipe_sampler_view **_views)
607d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson{
608f3cc4990a090ee076d8217c83aaf16e036e66686Brian Paul   galahad_context_set_sampler_views(_pipe, PIPE_SHADER_VERTEX,
609f3cc4990a090ee076d8217c83aaf16e036e66686Brian Paul                                     0, num, _views);
610f3cc4990a090ee076d8217c83aaf16e036e66686Brian Paul}
611d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
612f3cc4990a090ee076d8217c83aaf16e036e66686Brian Paulstatic void
613f3cc4990a090ee076d8217c83aaf16e036e66686Brian Paulgalahad_context_set_fragment_sampler_views(struct pipe_context *_pipe,
614f3cc4990a090ee076d8217c83aaf16e036e66686Brian Paul                                         unsigned num,
615f3cc4990a090ee076d8217c83aaf16e036e66686Brian Paul                                         struct pipe_sampler_view **_views)
616f3cc4990a090ee076d8217c83aaf16e036e66686Brian Paul{
617f3cc4990a090ee076d8217c83aaf16e036e66686Brian Paul   galahad_context_set_sampler_views(_pipe, PIPE_SHADER_FRAGMENT,
618f3cc4990a090ee076d8217c83aaf16e036e66686Brian Paul                                     0, num, _views);
619d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson}
620d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
621f3cc4990a090ee076d8217c83aaf16e036e66686Brian Paul
622d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpsonstatic void
6235b45775e415dac526a5729d7f4d99a1718206f09José Fonsecagalahad_context_set_vertex_buffers(struct pipe_context *_pipe,
624d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                            unsigned num_buffers,
625d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                            const struct pipe_vertex_buffer *_buffers)
626d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson{
627d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct galahad_context *glhd_pipe = galahad_context(_pipe);
628d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct pipe_context *pipe = glhd_pipe->pipe;
629d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct pipe_vertex_buffer unwrapped_buffers[PIPE_MAX_SHADER_INPUTS];
630d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct pipe_vertex_buffer *buffers = NULL;
631d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   unsigned i;
632d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
633d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   if (num_buffers) {
634d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson      memcpy(unwrapped_buffers, _buffers, num_buffers * sizeof(*_buffers));
635d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson      for (i = 0; i < num_buffers; i++)
636d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson         unwrapped_buffers[i].buffer = galahad_resource_unwrap(_buffers[i].buffer);
637d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson      buffers = unwrapped_buffers;
638d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   }
639d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
640d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   pipe->set_vertex_buffers(pipe,
641d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                            num_buffers,
642d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                            buffers);
643d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson}
6446d28bf917fb1d741d90fd3f05c22769376021fcaChia-I Wu
6456d28bf917fb1d741d90fd3f05c22769376021fcaChia-I Wustatic void
6465b45775e415dac526a5729d7f4d99a1718206f09José Fonsecagalahad_context_set_index_buffer(struct pipe_context *_pipe,
6476d28bf917fb1d741d90fd3f05c22769376021fcaChia-I Wu                         const struct pipe_index_buffer *_ib)
6486d28bf917fb1d741d90fd3f05c22769376021fcaChia-I Wu{
6496d28bf917fb1d741d90fd3f05c22769376021fcaChia-I Wu   struct galahad_context *glhd_pipe = galahad_context(_pipe);
6506d28bf917fb1d741d90fd3f05c22769376021fcaChia-I Wu   struct pipe_context *pipe = glhd_pipe->pipe;
6516d28bf917fb1d741d90fd3f05c22769376021fcaChia-I Wu   struct pipe_index_buffer unwrapped_ib, *ib = NULL;
6526d28bf917fb1d741d90fd3f05c22769376021fcaChia-I Wu
65304d29afb8b7329d66a1e9efc9fb55eb1adffa0dfJosé Fonseca   if (_ib) {
654f8e13e6d699b7251994cb367bf0609c54dccd87dJosé Fonseca      if (_ib->buffer || _ib->user_buffer) {
65504d29afb8b7329d66a1e9efc9fb55eb1adffa0dfJosé Fonseca         switch (_ib->index_size) {
65604d29afb8b7329d66a1e9efc9fb55eb1adffa0dfJosé Fonseca         case 1:
65704d29afb8b7329d66a1e9efc9fb55eb1adffa0dfJosé Fonseca         case 2:
65804d29afb8b7329d66a1e9efc9fb55eb1adffa0dfJosé Fonseca         case 4:
65904d29afb8b7329d66a1e9efc9fb55eb1adffa0dfJosé Fonseca            break;
66004d29afb8b7329d66a1e9efc9fb55eb1adffa0dfJosé Fonseca         default:
661f8e13e6d699b7251994cb367bf0609c54dccd87dJosé Fonseca            glhd_warn("unrecognized index size %d", _ib->index_size);
66204d29afb8b7329d66a1e9efc9fb55eb1adffa0dfJosé Fonseca            break;
66304d29afb8b7329d66a1e9efc9fb55eb1adffa0dfJosé Fonseca         }
66404d29afb8b7329d66a1e9efc9fb55eb1adffa0dfJosé Fonseca      }
66504d29afb8b7329d66a1e9efc9fb55eb1adffa0dfJosé Fonseca      else if (_ib->offset || _ib->index_size) {
66604d29afb8b7329d66a1e9efc9fb55eb1adffa0dfJosé Fonseca         glhd_warn("non-indexed state with index offset %d and index size %d",
66704d29afb8b7329d66a1e9efc9fb55eb1adffa0dfJosé Fonseca               _ib->offset, _ib->index_size);
6686d28bf917fb1d741d90fd3f05c22769376021fcaChia-I Wu      }
6696d28bf917fb1d741d90fd3f05c22769376021fcaChia-I Wu
6706d28bf917fb1d741d90fd3f05c22769376021fcaChia-I Wu      unwrapped_ib = *_ib;
6716d28bf917fb1d741d90fd3f05c22769376021fcaChia-I Wu      unwrapped_ib.buffer = galahad_resource_unwrap(_ib->buffer);
6726d28bf917fb1d741d90fd3f05c22769376021fcaChia-I Wu      ib = &unwrapped_ib;
6736d28bf917fb1d741d90fd3f05c22769376021fcaChia-I Wu   }
6746d28bf917fb1d741d90fd3f05c22769376021fcaChia-I Wu
6756d28bf917fb1d741d90fd3f05c22769376021fcaChia-I Wu   pipe->set_index_buffer(pipe, ib);
6766d28bf917fb1d741d90fd3f05c22769376021fcaChia-I Wu}
6776d28bf917fb1d741d90fd3f05c22769376021fcaChia-I Wu
678d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpsonstatic void
6795b45775e415dac526a5729d7f4d99a1718206f09José Fonsecagalahad_context_resource_copy_region(struct pipe_context *_pipe,
680d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                              struct pipe_resource *_dst,
6814c7001462607e6e99e474d6271dd481d3f8f201cRoland Scheidegger                              unsigned dst_level,
682d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                              unsigned dstx,
683d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                              unsigned dsty,
684d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                              unsigned dstz,
685d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                              struct pipe_resource *_src,
6864c7001462607e6e99e474d6271dd481d3f8f201cRoland Scheidegger                              unsigned src_level,
6874c7001462607e6e99e474d6271dd481d3f8f201cRoland Scheidegger                              const struct pipe_box *src_box)
688d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson{
689d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct galahad_context *glhd_pipe = galahad_context(_pipe);
690d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct galahad_resource *glhd_resource_dst = galahad_resource(_dst);
691d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct galahad_resource *glhd_resource_src = galahad_resource(_src);
692d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct pipe_context *pipe = glhd_pipe->pipe;
693d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct pipe_resource *dst = glhd_resource_dst->resource;
694d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct pipe_resource *src = glhd_resource_src->resource;
695d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
6963f758d4ed42f6b4c6bed60f8270ef908d3829ee5Corbin Simpson   if (_dst->format != _src->format) {
697f8e13e6d699b7251994cb367bf0609c54dccd87dJosé Fonseca      const struct util_format_description *src_desc =
698f8e13e6d699b7251994cb367bf0609c54dccd87dJosé Fonseca         util_format_description(_src->format);
699f8e13e6d699b7251994cb367bf0609c54dccd87dJosé Fonseca      const struct util_format_description *dst_desc =
700f8e13e6d699b7251994cb367bf0609c54dccd87dJosé Fonseca         util_format_description(_dst->format);
701f8e13e6d699b7251994cb367bf0609c54dccd87dJosé Fonseca      if (!util_is_format_compatible(src_desc, dst_desc))
702f8e13e6d699b7251994cb367bf0609c54dccd87dJosé Fonseca         glhd_warn("Format mismatch: Source is %s, destination is %s",
703f8e13e6d699b7251994cb367bf0609c54dccd87dJosé Fonseca            src_desc->short_name,
704f8e13e6d699b7251994cb367bf0609c54dccd87dJosé Fonseca            dst_desc->short_name);
7053f758d4ed42f6b4c6bed60f8270ef908d3829ee5Corbin Simpson   }
7063f758d4ed42f6b4c6bed60f8270ef908d3829ee5Corbin Simpson
7074ad63659c09499f4e538d71aec42035246747ffdMarek Olšák   if ((_src->target == PIPE_BUFFER && _dst->target != PIPE_BUFFER) ||
7084ad63659c09499f4e538d71aec42035246747ffdMarek Olšák       (_src->target != PIPE_BUFFER && _dst->target == PIPE_BUFFER)) {
7094ad63659c09499f4e538d71aec42035246747ffdMarek Olšák      glhd_warn("Resource target mismatch: Source is %i, destination is %i",
7104ad63659c09499f4e538d71aec42035246747ffdMarek Olšák                _src->target, _dst->target);
7114ad63659c09499f4e538d71aec42035246747ffdMarek Olšák   }
7124ad63659c09499f4e538d71aec42035246747ffdMarek Olšák
713d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   pipe->resource_copy_region(pipe,
714d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                              dst,
7154c7001462607e6e99e474d6271dd481d3f8f201cRoland Scheidegger                              dst_level,
716d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                              dstx,
717d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                              dsty,
718d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                              dstz,
719d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                              src,
7204c7001462607e6e99e474d6271dd481d3f8f201cRoland Scheidegger                              src_level,
7214c7001462607e6e99e474d6271dd481d3f8f201cRoland Scheidegger                              src_box);
722d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson}
723d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
724d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpsonstatic void
7255b45775e415dac526a5729d7f4d99a1718206f09José Fonsecagalahad_context_clear(struct pipe_context *_pipe,
726d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson               unsigned buffers,
7276dd284f7c8fac22f64c13fdf9909094f5ec59086Dave Airlie               const union pipe_color_union *color,
728d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson               double depth,
729d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson               unsigned stencil)
730d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson{
731d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct galahad_context *glhd_pipe = galahad_context(_pipe);
732d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct pipe_context *pipe = glhd_pipe->pipe;
733d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
734d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   pipe->clear(pipe,
735d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson               buffers,
7366dd284f7c8fac22f64c13fdf9909094f5ec59086Dave Airlie               color,
737d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson               depth,
738d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson               stencil);
739d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson}
740d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
741d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpsonstatic void
7425b45775e415dac526a5729d7f4d99a1718206f09José Fonsecagalahad_context_clear_render_target(struct pipe_context *_pipe,
743d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                             struct pipe_surface *_dst,
7446dd284f7c8fac22f64c13fdf9909094f5ec59086Dave Airlie                             const union pipe_color_union *color,
745d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                             unsigned dstx, unsigned dsty,
746d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                             unsigned width, unsigned height)
747d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson{
748d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct galahad_context *glhd_pipe = galahad_context(_pipe);
749d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct galahad_surface *glhd_surface_dst = galahad_surface(_dst);
750d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct pipe_context *pipe = glhd_pipe->pipe;
751d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct pipe_surface *dst = glhd_surface_dst->surface;
752d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
753d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   pipe->clear_render_target(pipe,
754d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                             dst,
7556dd284f7c8fac22f64c13fdf9909094f5ec59086Dave Airlie                             color,
756d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                             dstx,
757d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                             dsty,
758d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                             width,
759d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                             height);
760d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson}
761d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpsonstatic void
7625b45775e415dac526a5729d7f4d99a1718206f09José Fonsecagalahad_context_clear_depth_stencil(struct pipe_context *_pipe,
763d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                             struct pipe_surface *_dst,
764d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                             unsigned clear_flags,
765d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                             double depth,
766d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                             unsigned stencil,
767d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                             unsigned dstx, unsigned dsty,
768d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                             unsigned width, unsigned height)
769d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson{
770d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct galahad_context *glhd_pipe = galahad_context(_pipe);
771d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct galahad_surface *glhd_surface_dst = galahad_surface(_dst);
772d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct pipe_context *pipe = glhd_pipe->pipe;
773d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct pipe_surface *dst = glhd_surface_dst->surface;
774d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
775d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   pipe->clear_depth_stencil(pipe,
776d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                             dst,
777d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                             clear_flags,
778d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                             depth,
779d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                             stencil,
780d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                             dstx,
781d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                             dsty,
782d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                             width,
783d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                             height);
784d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
785d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson}
786d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
787d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpsonstatic void
7885b45775e415dac526a5729d7f4d99a1718206f09José Fonsecagalahad_context_flush(struct pipe_context *_pipe,
789d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson               struct pipe_fence_handle **fence)
790d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson{
791d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct galahad_context *glhd_pipe = galahad_context(_pipe);
792d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct pipe_context *pipe = glhd_pipe->pipe;
793d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
794d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   pipe->flush(pipe,
795d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson               fence);
796d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson}
797d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
798d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpsonstatic struct pipe_sampler_view *
799d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpsongalahad_context_create_sampler_view(struct pipe_context *_pipe,
800d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                                     struct pipe_resource *_resource,
801d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                                     const struct pipe_sampler_view *templ)
802d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson{
803d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct galahad_context *glhd_context = galahad_context(_pipe);
804d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct galahad_resource *glhd_resource = galahad_resource(_resource);
805d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct pipe_context *pipe = glhd_context->pipe;
806d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct pipe_resource *resource = glhd_resource->resource;
807d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct pipe_sampler_view *result;
808d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
809d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   result = pipe->create_sampler_view(pipe,
810d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                                      resource,
811d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                                      templ);
812d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
813d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   if (result)
814d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson      return galahad_sampler_view_create(glhd_context, glhd_resource, result);
815d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   return NULL;
816d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson}
817d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
818d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpsonstatic void
819d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpsongalahad_context_sampler_view_destroy(struct pipe_context *_pipe,
820d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                                      struct pipe_sampler_view *_view)
821d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson{
822d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   galahad_sampler_view_destroy(galahad_context(_pipe),
823d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                                 galahad_sampler_view(_view));
824d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson}
825d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
8264c7001462607e6e99e474d6271dd481d3f8f201cRoland Scheideggerstatic struct pipe_surface *
8274c7001462607e6e99e474d6271dd481d3f8f201cRoland Scheideggergalahad_context_create_surface(struct pipe_context *_pipe,
8284c7001462607e6e99e474d6271dd481d3f8f201cRoland Scheidegger                                struct pipe_resource *_resource,
8294c7001462607e6e99e474d6271dd481d3f8f201cRoland Scheidegger                                const struct pipe_surface *templ)
8304c7001462607e6e99e474d6271dd481d3f8f201cRoland Scheidegger{
8314c7001462607e6e99e474d6271dd481d3f8f201cRoland Scheidegger   struct galahad_context *glhd_context = galahad_context(_pipe);
8324c7001462607e6e99e474d6271dd481d3f8f201cRoland Scheidegger   struct galahad_resource *glhd_resource = galahad_resource(_resource);
8334c7001462607e6e99e474d6271dd481d3f8f201cRoland Scheidegger   struct pipe_context *pipe = glhd_context->pipe;
8344c7001462607e6e99e474d6271dd481d3f8f201cRoland Scheidegger   struct pipe_resource *resource = glhd_resource->resource;
8354c7001462607e6e99e474d6271dd481d3f8f201cRoland Scheidegger   struct pipe_surface *result;
8364c7001462607e6e99e474d6271dd481d3f8f201cRoland Scheidegger
8374c7001462607e6e99e474d6271dd481d3f8f201cRoland Scheidegger   result = pipe->create_surface(pipe,
8384c7001462607e6e99e474d6271dd481d3f8f201cRoland Scheidegger                                 resource,
8394c7001462607e6e99e474d6271dd481d3f8f201cRoland Scheidegger                                 templ);
8404c7001462607e6e99e474d6271dd481d3f8f201cRoland Scheidegger
8414c7001462607e6e99e474d6271dd481d3f8f201cRoland Scheidegger   if (result)
8424c7001462607e6e99e474d6271dd481d3f8f201cRoland Scheidegger      return galahad_surface_create(glhd_context, glhd_resource, result);
8434c7001462607e6e99e474d6271dd481d3f8f201cRoland Scheidegger   return NULL;
8444c7001462607e6e99e474d6271dd481d3f8f201cRoland Scheidegger}
8454c7001462607e6e99e474d6271dd481d3f8f201cRoland Scheidegger
8464c7001462607e6e99e474d6271dd481d3f8f201cRoland Scheideggerstatic void
8474c7001462607e6e99e474d6271dd481d3f8f201cRoland Scheideggergalahad_context_surface_destroy(struct pipe_context *_pipe,
8484c7001462607e6e99e474d6271dd481d3f8f201cRoland Scheidegger                                struct pipe_surface *_surface)
8494c7001462607e6e99e474d6271dd481d3f8f201cRoland Scheidegger{
8504c7001462607e6e99e474d6271dd481d3f8f201cRoland Scheidegger   galahad_surface_destroy(galahad_context(_pipe),
8514c7001462607e6e99e474d6271dd481d3f8f201cRoland Scheidegger                           galahad_surface(_surface));
8524c7001462607e6e99e474d6271dd481d3f8f201cRoland Scheidegger}
8534c7001462607e6e99e474d6271dd481d3f8f201cRoland Scheidegger
8544c7001462607e6e99e474d6271dd481d3f8f201cRoland Scheidegger
8554c7001462607e6e99e474d6271dd481d3f8f201cRoland Scheidegger
856d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpsonstatic struct pipe_transfer *
857d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpsongalahad_context_get_transfer(struct pipe_context *_context,
858d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                              struct pipe_resource *_resource,
8594c7001462607e6e99e474d6271dd481d3f8f201cRoland Scheidegger                              unsigned level,
860d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                              unsigned usage,
861d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                              const struct pipe_box *box)
862d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson{
863d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct galahad_context *glhd_context = galahad_context(_context);
864d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct galahad_resource *glhd_resource = galahad_resource(_resource);
865d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct pipe_context *context = glhd_context->pipe;
866d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct pipe_resource *resource = glhd_resource->resource;
867d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct pipe_transfer *result;
868d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
869d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   result = context->get_transfer(context,
870d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                                  resource,
8714c7001462607e6e99e474d6271dd481d3f8f201cRoland Scheidegger                                  level,
872d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                                  usage,
873d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                                  box);
874d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
875d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   if (result)
876d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson      return galahad_transfer_create(glhd_context, glhd_resource, result);
877d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   return NULL;
878d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson}
879d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
880d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpsonstatic void
881d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpsongalahad_context_transfer_destroy(struct pipe_context *_pipe,
882d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                                  struct pipe_transfer *_transfer)
883d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson{
884d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   galahad_transfer_destroy(galahad_context(_pipe),
885d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                             galahad_transfer(_transfer));
886d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson}
887d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
888d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpsonstatic void *
889d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpsongalahad_context_transfer_map(struct pipe_context *_context,
890d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                              struct pipe_transfer *_transfer)
891d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson{
892d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct galahad_context *glhd_context = galahad_context(_context);
893d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct galahad_transfer *glhd_transfer = galahad_transfer(_transfer);
894d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct pipe_context *context = glhd_context->pipe;
895d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct pipe_transfer *transfer = glhd_transfer->transfer;
896d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
8973b8182793b4f7d87ba274de152fb106996e75098Brian Paul   struct galahad_resource *glhd_resource = galahad_resource(_transfer->resource);
8983b8182793b4f7d87ba274de152fb106996e75098Brian Paul
8993b8182793b4f7d87ba274de152fb106996e75098Brian Paul   glhd_resource->map_count++;
9003b8182793b4f7d87ba274de152fb106996e75098Brian Paul
901d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   return context->transfer_map(context,
902d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                                transfer);
903d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson}
904d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
905d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
906d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
907d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpsonstatic void
908d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpsongalahad_context_transfer_flush_region(struct pipe_context *_context,
909d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                                       struct pipe_transfer *_transfer,
910d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                                       const struct pipe_box *box)
911d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson{
912d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct galahad_context *glhd_context = galahad_context(_context);
913d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct galahad_transfer *glhd_transfer = galahad_transfer(_transfer);
914d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct pipe_context *context = glhd_context->pipe;
915d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct pipe_transfer *transfer = glhd_transfer->transfer;
916d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
917d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   context->transfer_flush_region(context,
918d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                                  transfer,
919d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                                  box);
920d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson}
921d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
922d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
923d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpsonstatic void
924d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpsongalahad_context_transfer_unmap(struct pipe_context *_context,
925d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                                struct pipe_transfer *_transfer)
926d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson{
927d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct galahad_context *glhd_context = galahad_context(_context);
928d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct galahad_transfer *glhd_transfer = galahad_transfer(_transfer);
929d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct pipe_context *context = glhd_context->pipe;
930d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct pipe_transfer *transfer = glhd_transfer->transfer;
9313b8182793b4f7d87ba274de152fb106996e75098Brian Paul   struct galahad_resource *glhd_resource = galahad_resource(_transfer->resource);
9323b8182793b4f7d87ba274de152fb106996e75098Brian Paul
9333b8182793b4f7d87ba274de152fb106996e75098Brian Paul   if (glhd_resource->map_count < 1) {
9343b8182793b4f7d87ba274de152fb106996e75098Brian Paul      glhd_warn("context::transfer_unmap() called too many times"
9353b8182793b4f7d87ba274de152fb106996e75098Brian Paul                " (count = %d)\n", glhd_resource->map_count);
9363b8182793b4f7d87ba274de152fb106996e75098Brian Paul   }
9373b8182793b4f7d87ba274de152fb106996e75098Brian Paul
9383b8182793b4f7d87ba274de152fb106996e75098Brian Paul   glhd_resource->map_count--;
939d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
940d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   context->transfer_unmap(context,
941d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                           transfer);
942d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson}
943d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
944d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
945d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpsonstatic void
946d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpsongalahad_context_transfer_inline_write(struct pipe_context *_context,
947d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                                       struct pipe_resource *_resource,
9484c7001462607e6e99e474d6271dd481d3f8f201cRoland Scheidegger                                       unsigned level,
949d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                                       unsigned usage,
950d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                                       const struct pipe_box *box,
951d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                                       const void *data,
952d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                                       unsigned stride,
953d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                                       unsigned slice_stride)
954d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson{
955d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct galahad_context *glhd_context = galahad_context(_context);
956d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct galahad_resource *glhd_resource = galahad_resource(_resource);
957d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct pipe_context *context = glhd_context->pipe;
958d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct pipe_resource *resource = glhd_resource->resource;
959d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
960d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   context->transfer_inline_write(context,
961d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                                  resource,
9624c7001462607e6e99e474d6271dd481d3f8f201cRoland Scheidegger                                  level,
963d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                                  usage,
964d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                                  box,
965d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                                  data,
966d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                                  stride,
967d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson                                  slice_stride);
968d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson}
969d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
970d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
9713d2550be9c615431442a70812eb9faed01842dbfJosé Fonsecastatic void
9723d2550be9c615431442a70812eb9faed01842dbfJosé Fonsecagalahad_context_render_condition(struct pipe_context *_context,
9733d2550be9c615431442a70812eb9faed01842dbfJosé Fonseca                                 struct pipe_query *query,
9743d2550be9c615431442a70812eb9faed01842dbfJosé Fonseca                                 uint mode)
9753d2550be9c615431442a70812eb9faed01842dbfJosé Fonseca{
9763d2550be9c615431442a70812eb9faed01842dbfJosé Fonseca   struct galahad_context *glhd_context = galahad_context(_context);
9773d2550be9c615431442a70812eb9faed01842dbfJosé Fonseca   struct pipe_context *context = glhd_context->pipe;
9783d2550be9c615431442a70812eb9faed01842dbfJosé Fonseca
9793d2550be9c615431442a70812eb9faed01842dbfJosé Fonseca   context->render_condition(context, query, mode);
9803d2550be9c615431442a70812eb9faed01842dbfJosé Fonseca}
9813d2550be9c615431442a70812eb9faed01842dbfJosé Fonseca
9823d2550be9c615431442a70812eb9faed01842dbfJosé Fonseca
983d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpsonstruct pipe_context *
984d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpsongalahad_context_create(struct pipe_screen *_screen, struct pipe_context *pipe)
985d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson{
986d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   struct galahad_context *glhd_pipe;
987d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   (void)galahad_screen(_screen);
988d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
989d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   glhd_pipe = CALLOC_STRUCT(galahad_context);
990d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   if (!glhd_pipe) {
991d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson      return NULL;
992d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   }
993d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
994d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   glhd_pipe->base.screen = _screen;
995d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   glhd_pipe->base.priv = pipe->priv; /* expose wrapped data */
996d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   glhd_pipe->base.draw = NULL;
997d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
9985b45775e415dac526a5729d7f4d99a1718206f09José Fonseca   glhd_pipe->base.destroy = galahad_context_destroy;
9995b45775e415dac526a5729d7f4d99a1718206f09José Fonseca
10005b45775e415dac526a5729d7f4d99a1718206f09José Fonseca#define GLHD_PIPE_INIT(_member) \
10015b45775e415dac526a5729d7f4d99a1718206f09José Fonseca   glhd_pipe->base . _member = pipe -> _member ? galahad_context_ ## _member : NULL
10025b45775e415dac526a5729d7f4d99a1718206f09José Fonseca
10035b45775e415dac526a5729d7f4d99a1718206f09José Fonseca   GLHD_PIPE_INIT(draw_vbo);
10047bd926af8935f66e3a0e5c7d662c4ea6f30a54c6José Fonseca   GLHD_PIPE_INIT(render_condition);
10055b45775e415dac526a5729d7f4d99a1718206f09José Fonseca   GLHD_PIPE_INIT(create_query);
10065b45775e415dac526a5729d7f4d99a1718206f09José Fonseca   GLHD_PIPE_INIT(destroy_query);
10075b45775e415dac526a5729d7f4d99a1718206f09José Fonseca   GLHD_PIPE_INIT(begin_query);
10085b45775e415dac526a5729d7f4d99a1718206f09José Fonseca   GLHD_PIPE_INIT(end_query);
10095b45775e415dac526a5729d7f4d99a1718206f09José Fonseca   GLHD_PIPE_INIT(get_query_result);
10105b45775e415dac526a5729d7f4d99a1718206f09José Fonseca   GLHD_PIPE_INIT(create_blend_state);
10115b45775e415dac526a5729d7f4d99a1718206f09José Fonseca   GLHD_PIPE_INIT(bind_blend_state);
10125b45775e415dac526a5729d7f4d99a1718206f09José Fonseca   GLHD_PIPE_INIT(delete_blend_state);
10135b45775e415dac526a5729d7f4d99a1718206f09José Fonseca   GLHD_PIPE_INIT(create_sampler_state);
10145b45775e415dac526a5729d7f4d99a1718206f09José Fonseca   GLHD_PIPE_INIT(bind_fragment_sampler_states);
10155b45775e415dac526a5729d7f4d99a1718206f09José Fonseca   GLHD_PIPE_INIT(bind_vertex_sampler_states);
10167bd926af8935f66e3a0e5c7d662c4ea6f30a54c6José Fonseca   //GLHD_PIPE_INIT(bind_geometry_sampler_states);
10177bd926af8935f66e3a0e5c7d662c4ea6f30a54c6José Fonseca   //GLHD_PIPE_INIT(bind_compute_sampler_states);
10185b45775e415dac526a5729d7f4d99a1718206f09José Fonseca   GLHD_PIPE_INIT(delete_sampler_state);
10195b45775e415dac526a5729d7f4d99a1718206f09José Fonseca   GLHD_PIPE_INIT(create_rasterizer_state);
10205b45775e415dac526a5729d7f4d99a1718206f09José Fonseca   GLHD_PIPE_INIT(bind_rasterizer_state);
10215b45775e415dac526a5729d7f4d99a1718206f09José Fonseca   GLHD_PIPE_INIT(delete_rasterizer_state);
10225b45775e415dac526a5729d7f4d99a1718206f09José Fonseca   GLHD_PIPE_INIT(create_depth_stencil_alpha_state);
10235b45775e415dac526a5729d7f4d99a1718206f09José Fonseca   GLHD_PIPE_INIT(bind_depth_stencil_alpha_state);
10245b45775e415dac526a5729d7f4d99a1718206f09José Fonseca   GLHD_PIPE_INIT(delete_depth_stencil_alpha_state);
10255b45775e415dac526a5729d7f4d99a1718206f09José Fonseca   GLHD_PIPE_INIT(create_fs_state);
10265b45775e415dac526a5729d7f4d99a1718206f09José Fonseca   GLHD_PIPE_INIT(bind_fs_state);
10275b45775e415dac526a5729d7f4d99a1718206f09José Fonseca   GLHD_PIPE_INIT(delete_fs_state);
10285b45775e415dac526a5729d7f4d99a1718206f09José Fonseca   GLHD_PIPE_INIT(create_vs_state);
10295b45775e415dac526a5729d7f4d99a1718206f09José Fonseca   GLHD_PIPE_INIT(bind_vs_state);
10305b45775e415dac526a5729d7f4d99a1718206f09José Fonseca   GLHD_PIPE_INIT(delete_vs_state);
10317bd926af8935f66e3a0e5c7d662c4ea6f30a54c6José Fonseca   //GLHD_PIPE_INIT(create_gs_state);
10327bd926af8935f66e3a0e5c7d662c4ea6f30a54c6José Fonseca   //GLHD_PIPE_INIT(bind_gs_state);
10337bd926af8935f66e3a0e5c7d662c4ea6f30a54c6José Fonseca   //GLHD_PIPE_INIT(delete_gs_state);
10345b45775e415dac526a5729d7f4d99a1718206f09José Fonseca   GLHD_PIPE_INIT(create_vertex_elements_state);
10355b45775e415dac526a5729d7f4d99a1718206f09José Fonseca   GLHD_PIPE_INIT(bind_vertex_elements_state);
10365b45775e415dac526a5729d7f4d99a1718206f09José Fonseca   GLHD_PIPE_INIT(delete_vertex_elements_state);
10375b45775e415dac526a5729d7f4d99a1718206f09José Fonseca   GLHD_PIPE_INIT(set_blend_color);
10385b45775e415dac526a5729d7f4d99a1718206f09José Fonseca   GLHD_PIPE_INIT(set_stencil_ref);
10395b45775e415dac526a5729d7f4d99a1718206f09José Fonseca   GLHD_PIPE_INIT(set_sample_mask);
10407bd926af8935f66e3a0e5c7d662c4ea6f30a54c6José Fonseca   GLHD_PIPE_INIT(set_clip_state);
10415b45775e415dac526a5729d7f4d99a1718206f09José Fonseca   GLHD_PIPE_INIT(set_constant_buffer);
10425b45775e415dac526a5729d7f4d99a1718206f09José Fonseca   GLHD_PIPE_INIT(set_framebuffer_state);
10435b45775e415dac526a5729d7f4d99a1718206f09José Fonseca   GLHD_PIPE_INIT(set_polygon_stipple);
10445b45775e415dac526a5729d7f4d99a1718206f09José Fonseca   GLHD_PIPE_INIT(set_scissor_state);
10455b45775e415dac526a5729d7f4d99a1718206f09José Fonseca   GLHD_PIPE_INIT(set_viewport_state);
10465b45775e415dac526a5729d7f4d99a1718206f09José Fonseca   GLHD_PIPE_INIT(set_fragment_sampler_views);
10475b45775e415dac526a5729d7f4d99a1718206f09José Fonseca   GLHD_PIPE_INIT(set_vertex_sampler_views);
10487bd926af8935f66e3a0e5c7d662c4ea6f30a54c6José Fonseca   //GLHD_PIPE_INIT(set_geometry_sampler_views);
10497bd926af8935f66e3a0e5c7d662c4ea6f30a54c6José Fonseca   //GLHD_PIPE_INIT(set_compute_sampler_views);
10507bd926af8935f66e3a0e5c7d662c4ea6f30a54c6José Fonseca   //GLHD_PIPE_INIT(set_shader_resources);
10515b45775e415dac526a5729d7f4d99a1718206f09José Fonseca   GLHD_PIPE_INIT(set_vertex_buffers);
10525b45775e415dac526a5729d7f4d99a1718206f09José Fonseca   GLHD_PIPE_INIT(set_index_buffer);
10535b45775e415dac526a5729d7f4d99a1718206f09José Fonseca   //GLHD_PIPE_INIT(create_stream_output_target);
10545b45775e415dac526a5729d7f4d99a1718206f09José Fonseca   //GLHD_PIPE_INIT(stream_output_target_destroy);
10555b45775e415dac526a5729d7f4d99a1718206f09José Fonseca   //GLHD_PIPE_INIT(set_stream_output_targets);
10565b45775e415dac526a5729d7f4d99a1718206f09José Fonseca   GLHD_PIPE_INIT(resource_copy_region);
10577bd926af8935f66e3a0e5c7d662c4ea6f30a54c6José Fonseca   //GLHD_PIPE_INIT(resource_resolve);
10585b45775e415dac526a5729d7f4d99a1718206f09José Fonseca   GLHD_PIPE_INIT(clear);
10595b45775e415dac526a5729d7f4d99a1718206f09José Fonseca   GLHD_PIPE_INIT(clear_render_target);
10605b45775e415dac526a5729d7f4d99a1718206f09José Fonseca   GLHD_PIPE_INIT(clear_depth_stencil);
10615b45775e415dac526a5729d7f4d99a1718206f09José Fonseca   GLHD_PIPE_INIT(flush);
10627bd926af8935f66e3a0e5c7d662c4ea6f30a54c6José Fonseca   GLHD_PIPE_INIT(create_sampler_view);
10637bd926af8935f66e3a0e5c7d662c4ea6f30a54c6José Fonseca   GLHD_PIPE_INIT(sampler_view_destroy);
10647bd926af8935f66e3a0e5c7d662c4ea6f30a54c6José Fonseca   GLHD_PIPE_INIT(create_surface);
10657bd926af8935f66e3a0e5c7d662c4ea6f30a54c6José Fonseca   GLHD_PIPE_INIT(surface_destroy);
10665b45775e415dac526a5729d7f4d99a1718206f09José Fonseca   GLHD_PIPE_INIT(get_transfer);
10675b45775e415dac526a5729d7f4d99a1718206f09José Fonseca   GLHD_PIPE_INIT(transfer_destroy);
10685b45775e415dac526a5729d7f4d99a1718206f09José Fonseca   GLHD_PIPE_INIT(transfer_map);
10695b45775e415dac526a5729d7f4d99a1718206f09José Fonseca   GLHD_PIPE_INIT(transfer_flush_region);
10707bd926af8935f66e3a0e5c7d662c4ea6f30a54c6José Fonseca   GLHD_PIPE_INIT(transfer_unmap);
10715b45775e415dac526a5729d7f4d99a1718206f09José Fonseca   GLHD_PIPE_INIT(transfer_inline_write);
10727bd926af8935f66e3a0e5c7d662c4ea6f30a54c6José Fonseca   //GLHD_PIPE_INIT(texture_barrier);
10737bd926af8935f66e3a0e5c7d662c4ea6f30a54c6José Fonseca   //GLHD_PIPE_INIT(create_video_decoder);
10747bd926af8935f66e3a0e5c7d662c4ea6f30a54c6José Fonseca   //GLHD_PIPE_INIT(create_video_buffer);
10757bd926af8935f66e3a0e5c7d662c4ea6f30a54c6José Fonseca   //GLHD_PIPE_INIT(create_compute_state);
10767bd926af8935f66e3a0e5c7d662c4ea6f30a54c6José Fonseca   //GLHD_PIPE_INIT(bind_compute_state);
10777bd926af8935f66e3a0e5c7d662c4ea6f30a54c6José Fonseca   //GLHD_PIPE_INIT(delete_compute_state);
10787bd926af8935f66e3a0e5c7d662c4ea6f30a54c6José Fonseca   //GLHD_PIPE_INIT(set_compute_resources);
10797bd926af8935f66e3a0e5c7d662c4ea6f30a54c6José Fonseca   //GLHD_PIPE_INIT(set_global_binding);
10807bd926af8935f66e3a0e5c7d662c4ea6f30a54c6José Fonseca   //GLHD_PIPE_INIT(launch_grid);
10815b45775e415dac526a5729d7f4d99a1718206f09José Fonseca
10825b45775e415dac526a5729d7f4d99a1718206f09José Fonseca#undef GLHD_PIPE_INIT
1083d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
1084d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   glhd_pipe->pipe = pipe;
1085d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson
1086d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson   return &glhd_pipe->base;
1087d3ad6fa579d89d8c3ee27882d5baf8f8d2ecb3eaCorbin Simpson}
1088