1 /* -*- mode: C; c-file-style: "k&r"; tab-width 4; indent-tabs-mode: t; -*- */
4 * Copyright (C) 2013 Rob Clark <robclark@freedesktop.org>
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice (including the next
14 * paragraph) shall be included in all copies or substantial portions of the
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 * Rob Clark <robclark@freedesktop.org>
30 #include "fd2_context.h"
31 #include "fd2_blend.h"
35 #include "fd2_program.h"
36 #include "fd2_rasterizer.h"
37 #include "fd2_texture.h"
41 fd2_context_destroy(struct pipe_context
*pctx
)
44 fd_context_destroy(pctx
);
47 static struct pipe_resource
*
48 create_solid_vertexbuf(struct pipe_context
*pctx
)
50 static const float init_shader_const
[] = {
51 /* for clear/gmem2mem: */
52 -1.000000, +1.000000, +1.000000, +1.100000,
53 +1.000000, +1.000000, -1.000000, -1.100000,
54 +1.000000, +1.100000, -1.100000, +1.000000,
55 /* for mem2gmem: (vertices) */
56 -1.000000, +1.000000, +1.000000, +1.000000,
57 +1.000000, +1.000000, -1.000000, -1.000000,
58 +1.000000, +1.000000, -1.000000, +1.000000,
59 /* for mem2gmem: (tex coords) */
60 +0.000000, +0.000000, +1.000000, +0.000000,
61 +0.000000, +1.000000, +1.000000, +1.000000,
63 struct pipe_resource
*prsc
= pipe_buffer_create(pctx
->screen
,
64 PIPE_BIND_CUSTOM
, PIPE_USAGE_IMMUTABLE
, sizeof(init_shader_const
));
65 pipe_buffer_write(pctx
, prsc
, 0,
66 sizeof(init_shader_const
), init_shader_const
);
71 fd2_context_create(struct pipe_screen
*pscreen
, void *priv
)
73 struct fd2_context
*fd2_ctx
= CALLOC_STRUCT(fd2_context
);
74 struct pipe_context
*pctx
;
79 pctx
= &fd2_ctx
->base
.base
;
81 pctx
->destroy
= fd2_context_destroy
;
82 pctx
->create_blend_state
= fd2_blend_state_create
;
83 pctx
->create_rasterizer_state
= fd2_rasterizer_state_create
;
84 pctx
->create_depth_stencil_alpha_state
= fd2_zsa_state_create
;
88 fd2_texture_init(pctx
);
91 pctx
= fd_context_init(&fd2_ctx
->base
, pscreen
, priv
);
95 /* construct vertex state used for solid ops (clear, and gmem<->mem) */
96 fd2_ctx
->solid_vertexbuf
= create_solid_vertexbuf(pctx
);
98 fd2_emit_setup(&fd2_ctx
->base
);