Welcome to mirror list, hosted at ThFree Co, Russian Federation.

mtl_uniform_buffer.hh « metal « gpu « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 722d819cf96c0bd30cdbc1a339fac3aac4245251 (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
/* SPDX-License-Identifier: GPL-2.0-or-later */

/** \file
 * \ingroup gpu
 */

#pragma once

#include "MEM_guardedalloc.h"
#include "gpu_uniform_buffer_private.hh"

#include "mtl_context.hh"

namespace blender::gpu {

/**
 * Implementation of Uniform Buffers using Metal.
 **/
class MTLUniformBuf : public UniformBuf {
 private:
  /* Allocation Handle. */
  gpu::MTLBuffer *metal_buffer_ = nullptr;

  /* Whether buffer has contents, if false, no GPU buffer will
   * have yet been allocated. */
  bool has_data_ = false;

  /* Bindstate tracking. */
  int bind_slot_ = -1;
  MTLContext *bound_ctx_ = nullptr;

 public:
  MTLUniformBuf(size_t size, const char *name);
  ~MTLUniformBuf();

  void update(const void *data) override;
  void bind(int slot) override;
  void unbind() override;

  id<MTLBuffer> get_metal_buffer(int *r_offset);
  int get_size();
  const char *get_name()
  {
    return name_;
  }

  MEM_CXX_CLASS_ALLOC_FUNCS("MTLUniformBuf");
};

}  // namespace blender::gpu