Blender  V3.3
mtl_state.hh
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
7 #include "MEM_guardedalloc.h"
8 
9 #include "BLI_utildefines.h"
10 
11 #include "GPU_state.h"
12 #include "gpu_state_private.hh"
13 
14 namespace blender::gpu {
15 
16 /* Forward Declarations. */
17 class MTLContext;
18 
23 class MTLStateManager : public StateManager {
24  public:
25  private:
26  /* Current state of the associated MTLContext.
27  * Avoids resetting the whole state for every change. */
28  GPUState current_;
29  GPUStateMutable current_mutable_;
30  MTLContext *context_;
31 
32  public:
34 
35  void apply_state() override;
36  void force_state() override;
37 
38  void issue_barrier(eGPUBarrier barrier_bits) override;
39 
40  void texture_bind(Texture *tex, eGPUSamplerState sampler, int unit) override;
41  void texture_unbind(Texture *tex) override;
42  void texture_unbind_all() override;
43 
44  void image_bind(Texture *tex, int unit) override;
45  void image_unbind(Texture *tex) override;
46  void image_unbind_all() override;
47 
48  void texture_unpack_row_length_set(uint len) override;
49 
50  private:
51  void set_write_mask(const eGPUWriteMask value);
52  void set_depth_test(const eGPUDepthTest value);
53  void set_stencil_test(const eGPUStencilTest test, const eGPUStencilOp operation);
54  void set_stencil_mask(const eGPUStencilTest test, const GPUStateMutable state);
55  void set_clip_distances(const int new_dist_len, const int old_dist_len);
56  void set_logic_op(const bool enable);
57  void set_facing(const bool invert);
58  void set_backface_culling(const eGPUFaceCullTest test);
59  void set_provoking_vert(const eGPUProvokingVertex vert);
60  void set_shadow_bias(const bool enable);
61  void set_blend(const eGPUBlend value);
62 
63  void set_state(const GPUState &state);
64  void set_mutable_state(const GPUStateMutable &state);
65 
66  /* METAL State utility functions. */
67  void mtl_state_init();
68  void mtl_depth_range(float near, float far);
69  void mtl_stencil_mask(uint mask);
70  void mtl_stencil_set_func(eGPUStencilTest stencil_func, int ref, uint mask);
71 
72  MEM_CXX_CLASS_ALLOC_FUNCS("MTLStateManager")
73 };
74 
75 } // namespace blender::gpu
unsigned int uint
Definition: BLI_sys_types.h:67
eGPUBlend
Definition: GPU_state.h:59
eGPUWriteMask
Definition: GPU_state.h:11
eGPUProvokingVertex
Definition: GPU_state.h:113
eGPUFaceCullTest
Definition: GPU_state.h:107
eGPUBarrier
Definition: GPU_state.h:24
eGPUStencilOp
Definition: GPU_state.h:99
eGPUDepthTest
Definition: GPU_state.h:82
eGPUStencilTest
Definition: GPU_state.h:92
eGPUSamplerState
Definition: GPU_texture.h:25
Read Guarded memory(de)allocation.
void image_unbind_all() override
Definition: mtl_state.mm:628
void texture_unbind(Texture *tex) override
Definition: mtl_state.mm:596
void image_unbind(Texture *tex) override
Definition: mtl_state.mm:623
void force_state() override
Definition: mtl_state.mm:50
void image_bind(Texture *tex, int unit) override
Definition: mtl_state.mm:618
void texture_bind(Texture *tex, eGPUSamplerState sampler, int unit) override
Definition: mtl_state.mm:575
void texture_unpack_row_length_set(uint len) override
Definition: mtl_state.mm:568
void apply_state() override
Definition: mtl_state.mm:41
MTLStateManager(MTLContext *ctx)
Definition: mtl_state.mm:28
void issue_barrier(eGPUBarrier barrier_bits) override
Definition: mtl_state.mm:538
void texture_unbind_all() override
Definition: mtl_state.mm:605
int len
Definition: draw_manager.c:108
depth_tx sampler(1, ImageType::FLOAT_2D, "combined_tx") .sampler(2
CCL_NAMESPACE_BEGIN ccl_device float invert(float color, float factor)
Definition: invert.h:8
ccl_device_inline float4 mask(const int4 &mask, const float4 &a)
Definition: math_float4.h:513