Blender  V2.93
gpu_shader_private.hh
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
21 #pragma once
22 
23 #include "BLI_span.hh"
24 
25 #include "GPU_shader.h"
26 #include "gpu_shader_interface.hh"
28 
29 namespace blender {
30 namespace gpu {
31 
36 class Shader {
37  public:
39  ShaderInterface *interface = nullptr;
40 
41  protected:
43  char name[64];
44 
45  public:
46  Shader(const char *name);
47  virtual ~Shader();
48 
52  virtual bool finalize(void) = 0;
53 
55  const eGPUShaderTFBType geom_type) = 0;
57  virtual void transform_feedback_disable(void) = 0;
58 
59  virtual void bind(void) = 0;
60  virtual void unbind(void) = 0;
61 
62  virtual void uniform_float(int location, int comp_len, int array_size, const float *data) = 0;
63  virtual void uniform_int(int location, int comp_len, int array_size, const int *data) = 0;
64 
65  virtual void vertformat_from_shader(GPUVertFormat *) const = 0;
66 
67  /* DEPRECATED: Kept only because of BGL API. */
68  virtual int program_handle_get(void) const = 0;
69 
70  inline const char *const name_get(void) const
71  {
72  return name;
73  };
74 
75  protected:
76  void print_log(Span<const char *> sources, char *log, const char *stage, const bool error);
77 };
78 
79 /* Syntactic sugar. */
80 static inline GPUShader *wrap(Shader *vert)
81 {
82  return reinterpret_cast<GPUShader *>(vert);
83 }
84 static inline Shader *unwrap(GPUShader *vert)
85 {
86  return reinterpret_cast<Shader *>(vert);
87 }
88 static inline const Shader *unwrap(const GPUShader *vert)
89 {
90  return reinterpret_cast<const Shader *>(vert);
91 }
92 
93 } // namespace gpu
94 } // namespace blender
95 
96 /* XXX do not use it. Special hack to use OCIO with batch API. */
97 GPUShader *immGetShader(void);
struct GPUShader GPUShader
Definition: GPU_shader.h:33
eGPUShaderTFBType
Definition: GPU_shader.h:35
struct GPUVertBuf GPUVertBuf
virtual void uniform_int(int location, int comp_len, int array_size, const int *data)=0
void print_log(Span< const char * > sources, char *log, const char *stage, const bool error)
Definition: gpu_shader.cc:66
virtual void fragment_shader_from_glsl(MutableSpan< const char * > sources)=0
virtual bool transform_feedback_enable(GPUVertBuf *)=0
virtual int program_handle_get(void) const =0
virtual void vertex_shader_from_glsl(MutableSpan< const char * > sources)=0
virtual void unbind(void)=0
virtual void vertformat_from_shader(GPUVertFormat *) const =0
virtual void transform_feedback_names_set(Span< const char * > name_list, const eGPUShaderTFBType geom_type)=0
virtual void transform_feedback_disable(void)=0
virtual void bind(void)=0
virtual void geometry_shader_from_glsl(MutableSpan< const char * > sources)=0
const char *const name_get(void) const
virtual void uniform_float(int location, int comp_len, int array_size, const float *data)=0
Shader(const char *name)
Definition: gpu_shader.cc:249
virtual bool finalize(void)=0
EvaluationStage stage
Definition: deg_eval.cc:96
GPUShader * immGetShader(void)
static void error(const char *str)
Definition: meshlaplacian.c:65
INLINE Rall1d< T, V, S > log(const Rall1d< T, V, S > &arg)
Definition: rall1d.h:303
static GPUContext * wrap(Context *ctx)
static Context * unwrap(GPUContext *ctx)