2 * Copyright 2007 VMware, Inc.
3 * Copyright 2016 Advanced Micro Devices, Inc.
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * on the rights to use, copy, modify, merge, publish, distribute, sub
9 * license, and/or sell copies of the Software, and to permit persons to whom
10 * the Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
21 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
22 * USE OR OTHER DEALINGS IN THE SOFTWARE.
28 * Common helper functions for PBO up- and downloads.
31 #include "state_tracker/st_context.h"
32 #include "state_tracker/st_pbo.h"
34 #include "pipe/p_context.h"
35 #include "pipe/p_defines.h"
36 #include "pipe/p_screen.h"
37 #include "cso_cache/cso_context.h"
40 st_init_pbo_helpers(struct st_context
*st
)
42 struct pipe_context
*pipe
= st
->pipe
;
43 struct pipe_screen
*screen
= pipe
->screen
;
45 st
->pbo_upload
.enabled
=
46 screen
->get_param(screen
, PIPE_CAP_TEXTURE_BUFFER_OBJECTS
) &&
47 screen
->get_param(screen
, PIPE_CAP_TEXTURE_BUFFER_OFFSET_ALIGNMENT
) >= 1 &&
48 screen
->get_shader_param(screen
, PIPE_SHADER_FRAGMENT
, PIPE_SHADER_CAP_INTEGERS
);
49 if (!st
->pbo_upload
.enabled
)
52 st
->pbo_upload
.rgba_only
=
53 screen
->get_param(screen
, PIPE_CAP_BUFFER_SAMPLER_VIEW_RGBA_ONLY
);
55 if (screen
->get_param(screen
, PIPE_CAP_TGSI_INSTANCEID
)) {
56 if (screen
->get_param(screen
, PIPE_CAP_TGSI_VS_LAYER_VIEWPORT
)) {
57 st
->pbo_upload
.upload_layers
= true;
58 } else if (screen
->get_param(screen
, PIPE_CAP_MAX_GEOMETRY_OUTPUT_VERTICES
) >= 3) {
59 st
->pbo_upload
.upload_layers
= true;
60 st
->pbo_upload
.use_gs
= true;
65 memset(&st
->pbo_upload
.blend
, 0, sizeof(struct pipe_blend_state
));
66 st
->pbo_upload
.blend
.rt
[0].colormask
= PIPE_MASK_RGBA
;
68 /* Rasterizer state */
69 memset(&st
->pbo_upload
.raster
, 0, sizeof(struct pipe_rasterizer_state
));
70 st
->pbo_upload
.raster
.half_pixel_center
= 1;
74 st_destroy_pbo_helpers(struct st_context
*st
)
76 if (st
->pbo_upload
.fs
) {
77 cso_delete_fragment_shader(st
->cso_context
, st
->pbo_upload
.fs
);
78 st
->pbo_upload
.fs
= NULL
;
81 if (st
->pbo_upload
.gs
) {
82 cso_delete_geometry_shader(st
->cso_context
, st
->pbo_upload
.gs
);
83 st
->pbo_upload
.gs
= NULL
;
86 if (st
->pbo_upload
.vs
) {
87 cso_delete_vertex_shader(st
->cso_context
, st
->pbo_upload
.vs
);
88 st
->pbo_upload
.vs
= NULL
;