2
* Copyright (C) 2013 Rob Clark <robclark@freedesktop.org>
4
* Permission is hereby granted, free of charge, to any person obtaining a
5
* copy of this software and associated documentation files (the "Software"),
6
* to deal in the Software without restriction, including without limitation
7
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
8
* and/or sell copies of the Software, and to permit persons to whom the
9
* Software is furnished to do so, subject to the following conditions:
11
* The above copyright notice and this permission notice (including the next
12
* paragraph) shall be included in all copies or substantial portions of the
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 NONINFRINGEMENT. IN NO EVENT SHALL
18
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
* Rob Clark <robclark@freedesktop.org>
27
#include "fd2_context.h"
28
#include "fd2_blend.h"
32
#include "fd2_program.h"
33
#include "fd2_query.h"
34
#include "fd2_rasterizer.h"
35
#include "fd2_texture.h"
39
fd2_context_destroy(struct pipe_context *pctx) in_dt
41
fd_context_destroy(pctx);
45
static struct pipe_resource *
46
create_solid_vertexbuf(struct pipe_context *pctx)
48
/* clang-format off */
49
static const float init_shader_const[] = {
50
/* for clear/gmem2mem/mem2gmem (vertices): */
51
-1.000000f, +1.000000f, +1.000000f,
52
+1.000000f, +1.000000f, +1.000000f,
53
-1.000000f, -1.000000f, +1.000000f,
54
/* for mem2gmem: (tex coords) */
55
+0.000000f, +0.000000f,
56
+1.000000f, +0.000000f,
57
+0.000000f, +1.000000f,
58
/* SCREEN_SCISSOR_BR value (must be at 60 byte offset in page) */
60
/* zero indices dummy draw workaround (3 16-bit zeros) */
65
struct pipe_resource *prsc =
66
pipe_buffer_create(pctx->screen, PIPE_BIND_CUSTOM, PIPE_USAGE_IMMUTABLE,
67
sizeof(init_shader_const));
68
pipe_buffer_write(pctx, prsc, 0, sizeof(init_shader_const),
74
fd2_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
76
struct fd_screen *screen = fd_screen(pscreen);
77
struct fd2_context *fd2_ctx = CALLOC_STRUCT(fd2_context);
78
struct pipe_context *pctx;
83
pctx = &fd2_ctx->base.base;
84
pctx->screen = pscreen;
86
fd2_ctx->base.flags = flags;
87
fd2_ctx->base.dev = fd_device_ref(screen->dev);
88
fd2_ctx->base.screen = fd_screen(pscreen);
90
pctx->destroy = fd2_context_destroy;
91
pctx->create_blend_state = fd2_blend_state_create;
92
pctx->create_rasterizer_state = fd2_rasterizer_state_create;
93
pctx->create_depth_stencil_alpha_state = fd2_zsa_state_create;
97
fd2_texture_init(pctx);
101
pctx = fd_context_init(&fd2_ctx->base, pscreen, priv, flags);
105
/* construct vertex state used for solid ops (clear, and gmem<->mem) */
106
fd2_ctx->solid_vertexbuf = create_solid_vertexbuf(pctx);
108
fd2_query_context_init(pctx);