Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mesa
Path: blob/21.2-virgl/src/gallium/auxiliary/driver_noop/noop_state.c
4565 views
1
/*
2
* Copyright 2010 Red Hat Inc.
3
*
4
* Permission is hereby granted, free of charge, to any person obtaining a
5
* copy of this software and associated documentation files (the "Software"),
6
* to deal in the Software without restriction, including without limitation
7
* on the rights to use, copy, modify, merge, publish, distribute, sub
8
* license, and/or sell copies of the Software, and to permit persons to whom
9
* the Software is furnished to do so, subject to the following conditions:
10
*
11
* The above copyright notice and this permission notice (including the next
12
* paragraph) shall be included in all copies or substantial portions of the
13
* Software.
14
*
15
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18
* THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
19
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21
* USE OR OTHER DEALINGS IN THE SOFTWARE.
22
*/
23
#include <stdio.h>
24
#include <errno.h>
25
#include "pipe/p_defines.h"
26
#include "pipe/p_state.h"
27
#include "pipe/p_context.h"
28
#include "pipe/p_screen.h"
29
#include "util/u_memory.h"
30
#include "util/u_inlines.h"
31
#include "util/u_transfer.h"
32
33
static void noop_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info,
34
unsigned drawid_offset,
35
const struct pipe_draw_indirect_info *indirect,
36
const struct pipe_draw_start_count_bias *draws,
37
unsigned num_draws)
38
{
39
}
40
41
static void noop_launch_grid(struct pipe_context *ctx,
42
const struct pipe_grid_info *info)
43
{
44
}
45
46
static void noop_set_blend_color(struct pipe_context *ctx,
47
const struct pipe_blend_color *state)
48
{
49
}
50
51
static void *noop_create_blend_state(struct pipe_context *ctx,
52
const struct pipe_blend_state *state)
53
{
54
return MALLOC(1);
55
}
56
57
static void *noop_create_dsa_state(struct pipe_context *ctx,
58
const struct pipe_depth_stencil_alpha_state *state)
59
{
60
return MALLOC(1);
61
}
62
63
static void *noop_create_rs_state(struct pipe_context *ctx,
64
const struct pipe_rasterizer_state *state)
65
{
66
return MALLOC(1);
67
}
68
69
static void *noop_create_sampler_state(struct pipe_context *ctx,
70
const struct pipe_sampler_state *state)
71
{
72
return MALLOC(1);
73
}
74
75
static struct pipe_sampler_view *noop_create_sampler_view(struct pipe_context *ctx,
76
struct pipe_resource *texture,
77
const struct pipe_sampler_view *state)
78
{
79
struct pipe_sampler_view *sampler_view = CALLOC_STRUCT(pipe_sampler_view);
80
81
if (!sampler_view)
82
return NULL;
83
84
/* initialize base object */
85
*sampler_view = *state;
86
sampler_view->texture = NULL;
87
pipe_resource_reference(&sampler_view->texture, texture);
88
pipe_reference_init(&sampler_view->reference, 1);
89
sampler_view->context = ctx;
90
return sampler_view;
91
}
92
93
static struct pipe_surface *noop_create_surface(struct pipe_context *ctx,
94
struct pipe_resource *texture,
95
const struct pipe_surface *surf_tmpl)
96
{
97
struct pipe_surface *surface = CALLOC_STRUCT(pipe_surface);
98
99
if (!surface)
100
return NULL;
101
pipe_reference_init(&surface->reference, 1);
102
pipe_resource_reference(&surface->texture, texture);
103
surface->context = ctx;
104
surface->format = surf_tmpl->format;
105
surface->width = texture->width0;
106
surface->height = texture->height0;
107
surface->texture = texture;
108
surface->u.tex.first_layer = surf_tmpl->u.tex.first_layer;
109
surface->u.tex.last_layer = surf_tmpl->u.tex.last_layer;
110
surface->u.tex.level = surf_tmpl->u.tex.level;
111
112
return surface;
113
}
114
115
static void noop_set_sampler_views(struct pipe_context *ctx,
116
enum pipe_shader_type shader,
117
unsigned start, unsigned count,
118
unsigned unbind_num_trailing_slots,
119
struct pipe_sampler_view **views)
120
{
121
}
122
123
static void noop_bind_sampler_states(struct pipe_context *ctx,
124
enum pipe_shader_type shader,
125
unsigned start, unsigned count,
126
void **states)
127
{
128
}
129
130
static void noop_set_clip_state(struct pipe_context *ctx,
131
const struct pipe_clip_state *state)
132
{
133
}
134
135
static void noop_set_polygon_stipple(struct pipe_context *ctx,
136
const struct pipe_poly_stipple *state)
137
{
138
}
139
140
static void noop_set_sample_mask(struct pipe_context *pipe, unsigned sample_mask)
141
{
142
}
143
144
static void noop_set_scissor_states(struct pipe_context *ctx,
145
unsigned start_slot,
146
unsigned num_scissors,
147
const struct pipe_scissor_state *state)
148
{
149
}
150
151
static void noop_set_stencil_ref(struct pipe_context *ctx,
152
const struct pipe_stencil_ref state)
153
{
154
}
155
156
static void noop_set_viewport_states(struct pipe_context *ctx,
157
unsigned start_slot,
158
unsigned num_viewports,
159
const struct pipe_viewport_state *state)
160
{
161
}
162
163
static void noop_set_framebuffer_state(struct pipe_context *ctx,
164
const struct pipe_framebuffer_state *state)
165
{
166
}
167
168
static void noop_set_constant_buffer(struct pipe_context *ctx,
169
enum pipe_shader_type shader, uint index,
170
bool take_ownership,
171
const struct pipe_constant_buffer *cb)
172
{
173
}
174
175
static void noop_set_inlinable_constants(struct pipe_context *ctx,
176
enum pipe_shader_type shader,
177
uint num_values, uint32_t *values)
178
{
179
}
180
181
182
static void noop_sampler_view_destroy(struct pipe_context *ctx,
183
struct pipe_sampler_view *state)
184
{
185
pipe_resource_reference(&state->texture, NULL);
186
FREE(state);
187
}
188
189
190
static void noop_surface_destroy(struct pipe_context *ctx,
191
struct pipe_surface *surface)
192
{
193
pipe_resource_reference(&surface->texture, NULL);
194
FREE(surface);
195
}
196
197
static void noop_bind_state(struct pipe_context *ctx, void *state)
198
{
199
}
200
201
static void noop_delete_state(struct pipe_context *ctx, void *state)
202
{
203
FREE(state);
204
}
205
206
static void noop_set_vertex_buffers(struct pipe_context *ctx,
207
unsigned start_slot, unsigned count,
208
unsigned unbind_num_trailing_slots,
209
bool take_ownership,
210
const struct pipe_vertex_buffer *buffers)
211
{
212
}
213
214
static void *noop_create_vertex_elements(struct pipe_context *ctx,
215
unsigned count,
216
const struct pipe_vertex_element *state)
217
{
218
return MALLOC(1);
219
}
220
221
static void *noop_create_shader_state(struct pipe_context *ctx,
222
const struct pipe_shader_state *state)
223
{
224
return MALLOC(1);
225
}
226
227
static void *noop_create_compute_state(struct pipe_context *ctx,
228
const struct pipe_compute_state *state)
229
{
230
return MALLOC(1);
231
}
232
233
static struct pipe_stream_output_target *noop_create_stream_output_target(
234
struct pipe_context *ctx,
235
struct pipe_resource *res,
236
unsigned buffer_offset,
237
unsigned buffer_size)
238
{
239
struct pipe_stream_output_target *t = CALLOC_STRUCT(pipe_stream_output_target);
240
if (!t)
241
return NULL;
242
243
pipe_reference_init(&t->reference, 1);
244
pipe_resource_reference(&t->buffer, res);
245
t->buffer_offset = buffer_offset;
246
t->buffer_size = buffer_size;
247
return t;
248
}
249
250
static void noop_stream_output_target_destroy(struct pipe_context *ctx,
251
struct pipe_stream_output_target *t)
252
{
253
pipe_resource_reference(&t->buffer, NULL);
254
FREE(t);
255
}
256
257
static void noop_set_stream_output_targets(struct pipe_context *ctx,
258
unsigned num_targets,
259
struct pipe_stream_output_target **targets,
260
const unsigned *offsets)
261
{
262
}
263
264
static void noop_set_window_rectangles(struct pipe_context *ctx,
265
bool include,
266
unsigned num_rectangles,
267
const struct pipe_scissor_state *rects)
268
{
269
}
270
271
void noop_init_state_functions(struct pipe_context *ctx);
272
273
void noop_init_state_functions(struct pipe_context *ctx)
274
{
275
ctx->create_blend_state = noop_create_blend_state;
276
ctx->create_depth_stencil_alpha_state = noop_create_dsa_state;
277
ctx->create_fs_state = noop_create_shader_state;
278
ctx->create_rasterizer_state = noop_create_rs_state;
279
ctx->create_sampler_state = noop_create_sampler_state;
280
ctx->create_sampler_view = noop_create_sampler_view;
281
ctx->create_surface = noop_create_surface;
282
ctx->create_vertex_elements_state = noop_create_vertex_elements;
283
ctx->create_compute_state = noop_create_compute_state;
284
ctx->create_tcs_state = noop_create_shader_state;
285
ctx->create_tes_state = noop_create_shader_state;
286
ctx->create_gs_state = noop_create_shader_state;
287
ctx->create_vs_state = noop_create_shader_state;
288
ctx->bind_blend_state = noop_bind_state;
289
ctx->bind_depth_stencil_alpha_state = noop_bind_state;
290
ctx->bind_sampler_states = noop_bind_sampler_states;
291
ctx->bind_fs_state = noop_bind_state;
292
ctx->bind_rasterizer_state = noop_bind_state;
293
ctx->bind_vertex_elements_state = noop_bind_state;
294
ctx->bind_compute_state = noop_bind_state;
295
ctx->bind_tcs_state = noop_bind_state;
296
ctx->bind_tes_state = noop_bind_state;
297
ctx->bind_gs_state = noop_bind_state;
298
ctx->bind_vs_state = noop_bind_state;
299
ctx->delete_blend_state = noop_delete_state;
300
ctx->delete_depth_stencil_alpha_state = noop_delete_state;
301
ctx->delete_fs_state = noop_delete_state;
302
ctx->delete_rasterizer_state = noop_delete_state;
303
ctx->delete_sampler_state = noop_delete_state;
304
ctx->delete_vertex_elements_state = noop_delete_state;
305
ctx->delete_compute_state = noop_delete_state;
306
ctx->delete_tcs_state = noop_delete_state;
307
ctx->delete_tes_state = noop_delete_state;
308
ctx->delete_gs_state = noop_delete_state;
309
ctx->delete_vs_state = noop_delete_state;
310
ctx->set_blend_color = noop_set_blend_color;
311
ctx->set_clip_state = noop_set_clip_state;
312
ctx->set_constant_buffer = noop_set_constant_buffer;
313
ctx->set_inlinable_constants = noop_set_inlinable_constants;
314
ctx->set_sampler_views = noop_set_sampler_views;
315
ctx->set_framebuffer_state = noop_set_framebuffer_state;
316
ctx->set_polygon_stipple = noop_set_polygon_stipple;
317
ctx->set_sample_mask = noop_set_sample_mask;
318
ctx->set_scissor_states = noop_set_scissor_states;
319
ctx->set_stencil_ref = noop_set_stencil_ref;
320
ctx->set_vertex_buffers = noop_set_vertex_buffers;
321
ctx->set_viewport_states = noop_set_viewport_states;
322
ctx->set_window_rectangles = noop_set_window_rectangles;
323
ctx->sampler_view_destroy = noop_sampler_view_destroy;
324
ctx->surface_destroy = noop_surface_destroy;
325
ctx->draw_vbo = noop_draw_vbo;
326
ctx->launch_grid = noop_launch_grid;
327
ctx->create_stream_output_target = noop_create_stream_output_target;
328
ctx->stream_output_target_destroy = noop_stream_output_target_destroy;
329
ctx->set_stream_output_targets = noop_set_stream_output_targets;
330
}
331
332