compute_kernel.h
1 /*
2 ** ClanLib SDK
3 ** Copyright (c) 1997-2013 The ClanLib Team
4 **
5 ** This software is provided 'as-is', without any express or implied
6 ** warranty. In no event will the authors be held liable for any damages
7 ** arising from the use of this software.
8 **
9 ** Permission is granted to anyone to use this software for any purpose,
10 ** including commercial applications, and to alter it and redistribute it
11 ** freely, subject to the following restrictions:
12 **
13 ** 1. The origin of this software must not be misrepresented; you must not
14 ** claim that you wrote the original software. If you use this software
15 ** in a product, an acknowledgment in the product documentation would be
16 ** appreciated but is not required.
17 ** 2. Altered source versions must be plainly marked as such, and must not be
18 ** misrepresented as being the original software.
19 ** 3. This notice may not be removed or altered from any source distribution.
20 **
21 ** Note: Some of the libraries ClanLib may link to may have additional
22 ** requirements or restrictions.
23 **
24 ** File Author(s):
25 **
26 ** Magnus Norddahl
27 */
28 
29 
30 #pragma once
31 
32 #include "api_compute.h"
33 #include <memory>
34 #include "../Core/Math/vec4.h"
35 
36 namespace clan
37 {
40 
41 class ComputeProgram;
42 class ComputeBuffer;
43 class ComputeSampler;
44 class ComputeKernel_Impl;
45 
47 class CL_API_COMPUTE ComputeKernel
48 {
51 public:
53  ComputeKernel();
54 
59  ComputeKernel(ComputeProgram &program, const std::string &kernel_name);
60 
61  ~ComputeKernel();
63 
66 public:
68  bool is_null() const { return !impl; }
69 
71  void throw_if_null() const;
73 
76 public:
77  void set_arg(int index, const void *data, int size);
78  void set_arg_int(int index, int value);
79  void set_arg_float(int index, float value);
80  void set_arg_vec2f(int index, const Vec2f &value);
81  void set_arg_vec3f(int index, const Vec3f &value);
82  void set_arg_vec4f(int index, const Vec4f &value);
83  void set_arg_buffer(int index, ComputeBuffer &buffer);
84  void set_arg_sampler(int index, ComputeSampler &sampler);
85  void set_arg_null(int index);
87 
90 private:
91  std::shared_ptr<ComputeKernel_Impl> impl;
92 
93  friend class ComputeCommandQueue;
95 };
96 
97 }
98 
Compute buffer.
Definition: compute_buffer.h:52
bool is_null() const
Returns true if this object is invalid.
Definition: compute_kernel.h:68
Compute program kernel object.
Definition: compute_kernel.h:47
Compute command queue.
Definition: compute_command_queue.h:50
Compute program object.
Definition: compute_program.h:44
Compute sampler object.
Definition: compute_sampler.h:59