summaryrefslogtreecommitdiff
path: root/src/amd/vulkan/winsys/null/radv_null_cs.c
blob: fc76d5c6d4e8b53b263d2a0014b8b0a05231ee0b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*
 * Copyright © 2020 Valve Corporation
 *
 * based on amdgpu winsys.
 * Copyright © 2016 Red Hat.
 * Copyright © 2016 Bas Nieuwenhuizen
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice (including the next
 * paragraph) shall be included in all copies or substantial portions of the
 * Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 * IN THE SOFTWARE.
 */

#include "radv_null_cs.h"
#include "util/u_memory.h"

struct radv_null_cs {
	struct radeon_cmdbuf base;
	struct radv_null_winsys *ws;
};

static inline struct radv_null_cs *
radv_null_cs(struct radeon_cmdbuf *base)
{
	return (struct radv_null_cs*)base;
}

static struct radeon_winsys_ctx *radv_null_ctx_create(struct radeon_winsys *_ws,
						      enum radeon_ctx_priority priority)
{
	struct radv_null_ctx *ctx = CALLOC_STRUCT(radv_null_ctx);

	if (!ctx)
		return NULL;

	return (struct radeon_winsys_ctx *)ctx;

}

static void radv_null_ctx_destroy(struct radeon_winsys_ctx *rwctx)
{
	struct radv_null_ctx *ctx = (struct radv_null_ctx *)rwctx;
	FREE(ctx);
}

static struct radeon_cmdbuf *
radv_null_cs_create(struct radeon_winsys *ws,
		    enum ring_type ring_type)
{
	struct radv_null_cs *cs = calloc(1, sizeof(struct radv_null_cs));
	if (!cs)
		return NULL;

	cs->ws = radv_null_winsys(ws);

	cs->base.buf = malloc(16384);
	cs->base.max_dw = 4096;
	if (!cs->base.buf) {
		FREE(cs);
		return NULL;
	}

	return &cs->base;
}

static bool radv_null_cs_finalize(struct radeon_cmdbuf *_cs)
{
	return true;
}

static void radv_null_cs_destroy(struct radeon_cmdbuf *rcs)
{
	struct radv_null_cs *cs = radv_null_cs(rcs);
	FREE(cs->base.buf);
	FREE(cs);
}

void radv_null_cs_init_functions(struct radv_null_winsys *ws)
{
	ws->base.ctx_create = radv_null_ctx_create;
	ws->base.ctx_destroy = radv_null_ctx_destroy;
	ws->base.cs_create = radv_null_cs_create;
	ws->base.cs_finalize = radv_null_cs_finalize;
	ws->base.cs_destroy = radv_null_cs_destroy;

}