Changeset View
Changeset View
Standalone View
Standalone View
source/blender/gpu/metal/mtl_state.hh
| /* SPDX-License-Identifier: GPL-2.0-or-later */ | /* SPDX-License-Identifier: GPL-2.0-or-later */ | ||||
| /** \file | /** \file | ||||
| * \ingroup gpu | * \ingroup gpu | ||||
| */ | */ | ||||
| #pragma once | |||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| #include "BLI_utildefines.h" | #include "BLI_utildefines.h" | ||||
| #include "GPU_state.h" | #include "GPU_state.h" | ||||
| #include "gpu_state_private.hh" | #include "gpu_state_private.hh" | ||||
| #include "mtl_pso_descriptor_state.hh" | |||||
| namespace blender::gpu { | namespace blender::gpu { | ||||
| /* Forward Declarations. */ | /* Forward Declarations. */ | ||||
| class MTLContext; | class MTLContext; | ||||
| /** | /** | ||||
| * State manager keeping track of the draw state and applying it before drawing. | * State manager keeping track of the draw state and applying it before drawing. | ||||
| * Metal Implementation. | * Metal Implementation. | ||||
| **/ | **/ | ||||
| class MTLStateManager : public StateManager { | class MTLStateManager : public StateManager { | ||||
| public: | |||||
| private: | private: | ||||
| /* Current state of the associated MTLContext. | /* Current state of the associated MTLContext. | ||||
| * Avoids resetting the whole state for every change. */ | * Avoids resetting the whole state for every change. */ | ||||
| GPUState current_; | GPUState current_; | ||||
| GPUStateMutable current_mutable_; | GPUStateMutable current_mutable_; | ||||
| MTLContext *context_; | MTLContext *context_; | ||||
| /* Global pipeline descriptors. */ | |||||
| MTLRenderPipelineStateDescriptor pipeline_descriptor_; | |||||
| public: | public: | ||||
| MTLStateManager(MTLContext *ctx); | MTLStateManager(MTLContext *ctx); | ||||
| void apply_state() override; | void apply_state() override; | ||||
| void force_state() override; | void force_state() override; | ||||
| void issue_barrier(eGPUBarrier barrier_bits) override; | void issue_barrier(eGPUBarrier barrier_bits) override; | ||||
| void texture_bind(Texture *tex, eGPUSamplerState sampler, int unit) override; | void texture_bind(Texture *tex, eGPUSamplerState sampler, int unit) override; | ||||
| void texture_unbind(Texture *tex) override; | void texture_unbind(Texture *tex) override; | ||||
| void texture_unbind_all() override; | void texture_unbind_all() override; | ||||
| void image_bind(Texture *tex, int unit) override; | void image_bind(Texture *tex, int unit) override; | ||||
| void image_unbind(Texture *tex) override; | void image_unbind(Texture *tex) override; | ||||
| void image_unbind_all() override; | void image_unbind_all() override; | ||||
| void texture_unpack_row_length_set(uint len) override; | void texture_unpack_row_length_set(uint len) override; | ||||
| /* Global pipeline descriptors. */ | |||||
| MTLRenderPipelineStateDescriptor &get_pipeline_descriptor() | |||||
| { | |||||
| return pipeline_descriptor_; | |||||
| } | |||||
| private: | private: | ||||
| void set_write_mask(const eGPUWriteMask value); | void set_write_mask(const eGPUWriteMask value); | ||||
| void set_depth_test(const eGPUDepthTest value); | void set_depth_test(const eGPUDepthTest value); | ||||
| void set_stencil_test(const eGPUStencilTest test, const eGPUStencilOp operation); | void set_stencil_test(const eGPUStencilTest test, const eGPUStencilOp operation); | ||||
| void set_stencil_mask(const eGPUStencilTest test, const GPUStateMutable state); | void set_stencil_mask(const eGPUStencilTest test, const GPUStateMutable state); | ||||
| void set_clip_distances(const int new_dist_len, const int old_dist_len); | void set_clip_distances(const int new_dist_len, const int old_dist_len); | ||||
| void set_logic_op(const bool enable); | void set_logic_op(const bool enable); | ||||
| void set_facing(const bool invert); | void set_facing(const bool invert); | ||||
| Show All 18 Lines | |||||