1b8e80941Smrg/*
2b8e80941Smrg * Copyright 2017 Advanced Micro Devices, Inc.
3b8e80941Smrg * All Rights Reserved.
4b8e80941Smrg *
5b8e80941Smrg * Permission is hereby granted, free of charge, to any person obtaining a
6b8e80941Smrg * copy of this software and associated documentation files (the "Software"),
7b8e80941Smrg * to deal in the Software without restriction, including without limitation
8b8e80941Smrg * on the rights to use, copy, modify, merge, publish, distribute, sub
9b8e80941Smrg * license, and/or sell copies of the Software, and to permit persons to whom
10b8e80941Smrg * the Software is furnished to do so, subject to the following conditions:
11b8e80941Smrg *
12b8e80941Smrg * The above copyright notice and this permission notice (including the next
13b8e80941Smrg * paragraph) shall be included in all copies or substantial portions of the
14b8e80941Smrg * Software.
15b8e80941Smrg *
16b8e80941Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17b8e80941Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18b8e80941Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
19b8e80941Smrg * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
20b8e80941Smrg * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
21b8e80941Smrg * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
22b8e80941Smrg * USE OR OTHER DEALINGS IN THE SOFTWARE.
23b8e80941Smrg */
24b8e80941Smrg
25b8e80941Smrg#ifndef SI_COMPUTE_H
26b8e80941Smrg#define SI_COMPUTE_H
27b8e80941Smrg
28b8e80941Smrg#include "util/u_inlines.h"
29b8e80941Smrg
30b8e80941Smrg#include "si_shader.h"
31b8e80941Smrg
32b8e80941Smrg#define MAX_GLOBAL_BUFFERS 32
33b8e80941Smrg
34b8e80941Smrgstruct si_compute {
35b8e80941Smrg	struct pipe_reference reference;
36b8e80941Smrg	struct si_screen *screen;
37b8e80941Smrg	union {
38b8e80941Smrg		struct tgsi_token *tgsi;
39b8e80941Smrg		struct nir_shader *nir;
40b8e80941Smrg	} ir;
41b8e80941Smrg	struct util_queue_fence ready;
42b8e80941Smrg	struct si_compiler_ctx_state compiler_ctx_state;
43b8e80941Smrg
44b8e80941Smrg	/* bitmasks of used descriptor slots */
45b8e80941Smrg	uint32_t active_const_and_shader_buffers;
46b8e80941Smrg	uint64_t active_samplers_and_images;
47b8e80941Smrg
48b8e80941Smrg	unsigned ir_type;
49b8e80941Smrg	unsigned local_size;
50b8e80941Smrg	unsigned private_size;
51b8e80941Smrg	unsigned input_size;
52b8e80941Smrg	struct si_shader shader;
53b8e80941Smrg
54b8e80941Smrg	struct pipe_resource *global_buffers[MAX_GLOBAL_BUFFERS];
55b8e80941Smrg	unsigned use_code_object_v2 : 1;
56b8e80941Smrg	unsigned uses_grid_size:1;
57b8e80941Smrg	unsigned uses_bindless_samplers:1;
58b8e80941Smrg	unsigned uses_bindless_images:1;
59b8e80941Smrg	bool reads_variable_block_size;
60b8e80941Smrg	unsigned num_cs_user_data_dwords;
61b8e80941Smrg};
62b8e80941Smrg
63b8e80941Smrgvoid si_destroy_compute(struct si_compute *program);
64b8e80941Smrg
65b8e80941Smrgstatic inline void
66b8e80941Smrgsi_compute_reference(struct si_compute **dst, struct si_compute *src)
67b8e80941Smrg{
68b8e80941Smrg	if (pipe_reference(&(*dst)->reference, &src->reference))
69b8e80941Smrg		si_destroy_compute(*dst);
70b8e80941Smrg
71b8e80941Smrg	*dst = src;
72b8e80941Smrg}
73b8e80941Smrg
74b8e80941Smrg#endif /* SI_COMPUTE_H */
75